Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official. ×

By MikeMirzayanov, 14 months ago, ,

Codeforces Round 440 will start on October 15 (Sunday), 08:05 (UTC). It will be based on Technocup 2018 Elimination Round 2. So, if you are a Russian-speaking high-school student, please take part in the Technocup 2018.

Codeforces Round 440 is open and rated for everyone.

Wish you good luck and bugless code.

Editorial is posted.

Congratulations to winners!

Technocup official round:

Div. 1:

Div. 2:

•
• +188
•

 » 14 months ago, # |   +39 Mandatory comment- "Hope the problem statements are as short as this blog".
 » 14 months ago, # |   +110 Clash with OpenCup. ;(
 » 14 months ago, # |   +75 Is it me or is the contest title is longer than the announcement :3
•  » » 14 months ago, # ^ |   -13 oh jeez rick !
 » 14 months ago, # |   +3 I guess it's the first time that we don't see any "thanks" or even any username in an announcement :D
•  » » 14 months ago, # ^ |   0 well it would be mike thanking himself :)
 » 14 months ago, # |   -7 This is like the shortest announcement ever of all time.
 » 14 months ago, # |   +25 A good time for Chinese students!
•  » » 14 months ago, # ^ |   +37 for Asian students!
•  » » 14 months ago, # ^ |   +3 And Australian!
 » 14 months ago, # |   0 I have an onsite contest after 15mins for 5 hours, and then I can take part in this cf round. A good time for me.
 » 14 months ago, # | ← Rev. 2 →   -32 I have doubt.When I opened 'contests' page, it showed me two separate contests(div1 and div2), but in the announcement it is given (Div1 + Div2). Which one it is going to be ? MikeMirzayanov UPD : when I posted this comment, there were only 2 contests. (contests 440Div1 , 440Div2). That's why I got confused. Right now contests page is fully updated. Apu_hasan
•  » » 14 months ago, # ^ |   -28 dont't be stupid
 » 14 months ago, # |   +14 I Wish everyone positive rating!
•  » » 14 months ago, # ^ |   +19 You have to be really bad to have a negative rating (like worse), so the wish is likely to come true.
•  » » » 14 months ago, # ^ |   0 And yet he's managed to disprove this
 » 14 months ago, # |   +4 why do timing varies a lot recently ??
 » 14 months ago, # |   -25 I hope I won't get a WA on problem A, the way it happened in the previous contest :(
•  » » 14 months ago, # ^ |   +27 In previous contest U got TLE.
•  » » 12 months ago, # ^ |   0 Nobody cares anyway :D
 » 14 months ago, # |   +26 It will be at 3 AM here in Colombia. Guess is a good way to start a Sunday ¯_(ツ)_/¯ .
 » 14 months ago, # |   -12 2 PM in Bangladesh..Surely the best time except for missing lunch
 » 14 months ago, # |   +12 The Terms of agreement when registering is in Russian "Вы подтверждаете, что будете работать самостоятельно во всех этапах Технокубка и не будете нарушать какие-либо другие правила." So I'm wondering whether an English version of problem statements will be given during the real contest. Can anyone explain about this a little bit? Thanks a lot.
•  » » 14 months ago, # ^ |   +10 There will be english statements
 » 14 months ago, # |   -7 Will surely hack this time !!! :)
 » 14 months ago, # |   -8 gl hf
 » 14 months ago, # |   0 number of problems and the difficulty is about the 1st round ? because that round was easier than ususal
 » 14 months ago, # | ← Rev. 2 →   +10 What's the "Practice Round 2"?EDIT: never mind, seems to be for Technocup official participants only
 » 14 months ago, # |   +13 Hope there will be no geometry problems
•  » » 14 months ago, # ^ |   +1 why don't you like geometry problems?
•  » » 14 months ago, # ^ |   +11 geometry is good, it makes people cry T_T
 » 14 months ago, # |   0 May be it's a silly question.but what does "00:04" like things below every submission means??is it time of submission or what
•  » » 14 months ago, # ^ |   0 You mean the time that is shown below the submission during the contest.Its the time when you've submitted the solution after the start of the contest. '00:04' Would mean that you've submitted the solution after 4 minutes
 » 14 months ago, # |   0 How long will the contest last?
•  » » 14 months ago, # ^ |   +6 2 hrs
 » 14 months ago, # |   +32 have no time to receive it :D
 » 14 months ago, # |   +1 Why can I register for both Codeforces Round 440 (Div 1) and Technocup 2018 round 2?
 » 14 months ago, # |   +35 How many problems?
 » 14 months ago, # |   -16 "...and thanks to MikeMirzayanov for the fantastic Codeforces and Polygon platforms."Just for keeping the rituals :D
 » 14 months ago, # |   0 How many problems? How many shared problems?
 » 14 months ago, # |   +1 YouHaveShort Blog.
 » 14 months ago, # |   0 Registration button didn't work for me...
•  » » 14 months ago, # ^ |   0 Still can't register in div.2 ((
•  » » » 14 months ago, # ^ |   0 Russian-speaking high-school students have to register in this contest.[contest:http://codeforces.com/contest/870]
 » 14 months ago, # |   +29 Mandatory comment- "Thankyou for the short problem statements".
 » 14 months ago, # | ← Rev. 4 →   0 I am seeing people resubmitting after their solutions were hacked. Is this normal ? Screenshot Edit : Sorry ! The problem wasn't locked until that moment, that's why they were able to resubmit.
 » 14 months ago, # |   +41 Disclaimer: My argument may be wrong, and if it is, I don't mean to offend anyone, so apologies in advance. The contestant who is currently second (at the time of commenting) in the leaderboard looks mighty suspicious. He has solves solves for 3 different problems in the space of 6 minutes, including solving D in 2 minutes. Check out his submissions.
•  » » 14 months ago, # ^ | ← Rev. 3 →   +2 How is it possible to do D problem in 2 minutes :O.Is it a joke? :|
•  » » 14 months ago, # ^ |   -10 Same case in hackerrank. People have multiple accounts, view problems from one account and once they got the solutions, they submit all at once.
•  » » » 14 months ago, # ^ |   +11 That doesn't work here.
•  » » » » 14 months ago, # ^ |   0 Ahh, I didn't know that. Thanks !
•  » » 14 months ago, # ^ |   +6 Looks like someone else submitted his C first and later he resubmitted. Look at the programs. There is no template in the first submission of C.
•  » » 14 months ago, # ^ |   +13 I think pulkit.kapoor can explain better
•  » » » 14 months ago, # ^ |   +31 It's extremely sad, given nothing has been done about this. The contestant was not kicked out of the contest, and even received a significantly large rating increase (+281). Please look into this MikeMirzayanov, KAN.
 » 14 months ago, # |   +65 In Div-1 B, just ask n queries of the form (i, 0) and n queries of the form (0, i).Now, if you know p[i], you can get p[j] using p[i] ^ query(i, 0) ^ query(j, 0).And if you know b[i], you can get b[j] using b[i] ^ query(0, i) ^ query(0, j). Now, one by one, fix the the value of p[0] from 0 to n-1. Then you can recover the whole permutation p[].You know that b[p[0]] = 0, so you can recover the whole inverse permutation b[] as well. Check if both are valid. All elements of p[] are distinct and 0 <= p[i] < n && b[p[i]] = i.It this is true, this is a valid answer. Simply count the total and print any one of these.
•  » » 14 months ago, # ^ |   +10 I only stuck for checking is it valid permutation. Simply I do not see why it means that all n2 pairs will produce correct answer as valid permutation.
•  » » » 14 months ago, # ^ |   +41 If you do these 2n queries all other queries are redundant.Q(i, j) = Q(i, 0) ^ Q(0, 0) ^ Q(0, j)
•  » » 14 months ago, # ^ |   +6 Yeah so querying these is enough.
•  » » 14 months ago, # ^ |   0 I did not check that p[] are distinct, but I don't think that there could be 2 the same elements.
•  » » 14 months ago, # ^ | ← Rev. 3 →   0 All elements of p are always distinct in all potential permutations.Say pi = pj. But then xor(pi, pj) = 0. Hence pi = pj in all potential permutations and there is no answer.
•  » » 14 months ago, # ^ |   0 Besides, you need to apply this procedure only for even n. For odd n, p0 is uniquely determined, hence only one possible permutation.
•  » » 14 months ago, # ^ |   0 My solution:I first find the value of a[0]^b[i] for all 0<=i
•  » » » 14 months ago, # ^ |   0 Since you haven't done queries of the form query(i, 0), the information you have is not equivalent to all the information you would have if you made all n2 queries.
•  » » » » 14 months ago, # ^ |   0 Got it. Thanks :)
 » 14 months ago, # |   +1 Ok, so what are the hacks on B? Thanks for short statements, by the way.
•  » » 14 months ago, # ^ |   0 3 2 1 8 1
•  » » 14 months ago, # ^ | ← Rev. 2 →   0 Case : k = 25 21 2 5 4 3Answer : 3
•  » » 14 months ago, # ^ |   -7 Depends on the solution. I used the following hack a lot for the ones who used sorting:3 21 2 1
 » 14 months ago, # |   0 literally 1 sec from submitting D and the contest ends :/ .
 » 14 months ago, # |   +11 How to solve Div-1 C?
•  » » 14 months ago, # ^ | ← Rev. 2 →   +76 Let's say that two points are connected if they lie on the same horizontal or vertical line. Find connected components. For each of them, let L denote the number of possible different lines you can draw, and let P denote the number of points.For example, for a single point L = 2 and P = 1. For two points with the same y-coordinate it would be L = 3 and P = 2. For the sample test with four points it would be L = 4 and P = 4.It turns out that you can draw a subset of L possible lines if and only if its size doesn't exceed P. So the answer for this connected component is .
•  » » » 14 months ago, # ^ |   +11 What is X?
•  » » » » 14 months ago, # ^ |   0 sry, it was supposed to be P. corrected now.
•  » » » » » 14 months ago, # ^ |   0 Thanks! Great solution really. I was taking quite a complicated route only to arrive at the wrong formula.
•  » » » » 14 months ago, # ^ |   0 I think he meant P.
•  » » » 14 months ago, # ^ |   +77 You can also note that P ≥ L - 1, so the answer is either 2L or 2L - 1.
•  » » » » 14 months ago, # ^ |   +8 nice, missed that
•  » » » » 14 months ago, # ^ | ← Rev. 2 →   0 But for second example, output is 9, which is neither in 2^L nor 2^(L-1) format
•  » » » » » 14 months ago, # ^ |   +3 for each component he means that example has 2
•  » » 14 months ago, # ^ | ← Rev. 2 →   +23 Make a bipartite graph like this :In one of the parts put a node for every x. And in the other part put a node for every y. Now a point in the problem at coordinate (xi, yi) is an edge in the graph that is between node xi in th first part and the node yi in the other part .Now consider a connected component , consider that it has k nodes.If this component has a cycle , then you can make all 2k states for horizontal or vertical lines in this component .Otherwise when the component is a tree you can make all of the states minus the state that all the nodes (vertical and horizontal lines) appeared , so it has 2k - 1 states!
•  » » 14 months ago, # ^ |   0 I see Div1 C smth likes ARC83 F: https://atcoder.jp/img/arc083/editorial.pdf.
 » 14 months ago, # |   0 Hints for Div2 E?
 » 14 months ago, # | ← Rev. 2 →   0 how to do C?? i submitted in last 3 min..if(x&1 || x<4) ans=-1;if(x%4) ans=x/4else ans=[(x-6)/4]+1
•  » » 14 months ago, # ^ |   +11  if (n % 4 == 0) return n / 4; else if (n % 4 == 1) return (n - 9) / 4 + 1; else if (n % 4 == 2) return (n - 6) / 4 + 1; else if (n % 4 == 3) return (n - 15) / 4 + 2; 
•  » » » 14 months ago, # ^ | ← Rev. 2 →   0 for (n%4==3) (n-15)/4+1 or (n-15)/4+2??
•  » » » » 14 months ago, # ^ |   0 (n-15)/4+2
•  » » » » » 14 months ago, # ^ |   0 why?? for 27=4+4+4+15 it's 4 not 5!!
•  » » » » » » 14 months ago, # ^ |   0 15 is 6 + 9 :)
•  » » » 14 months ago, # ^ | ← Rev. 4 →   0 if (n < 4 || n == 5 || n == 7 || n == 11) cout << -1 << \n; else cout << n / 4 — n % 2;
•  » » » » 14 months ago, # ^ |   0 fail for 9
•  » » » » » 14 months ago, # ^ |   0 there should be a "-" instead of "+"
•  » » » » 14 months ago, # ^ |   0 n/4 — n % 2 is correct for all n>=12 for 1,2,3,5,7,11 ans = -1 For 4, 6, 9 ans = 1 For 8, 10 ans = 2
•  » » » » » 14 months ago, # ^ |   0 i misspelled it, it's a "-" there for all of the numbers, instead those cases that I wrote
•  » » 14 months ago, # ^ |   +4 "if(x&1 || x<4) ans=-1;"This is wrong. What if x = 9?
•  » » 14 months ago, # ^ | ← Rev. 6 →   0 My logic was:if N is Even:        If N < 4: -1;       Else If N >= 4: N / 4;else N is Odd:       If N >= 9 and N != 11: 1 + (N — 9) / 4;       Else : -1;
•  » » » 14 months ago, # ^ | ← Rev. 2 →   +1 You logic prints out 2 if N = 11. This is wrong.
•  » » » » 14 months ago, # ^ | ← Rev. 3 →   0 I mixed up the even and odd case. It is correct now.
•  » » 14 months ago, # ^ | ← Rev. 13 →   0 every number 11 > can be expressed as sum of composite numbersso if n<=11: you can precalculate that thatelse if (n & 1) n-9,ans++ if (n % 4 != 0) n-6,ans++ans += n/4
•  » » 14 months ago, # ^ |   0 public static int solve(int n) { int c=0; if(n%2==1) { n-=9; c++; } if(n%4==2) { n-=6; c++; } if(n<0) { return -1; } return c+n/4; } 31347433
•  » » 14 months ago, # ^ |   0 if(n==2 || (n%2!=0 && n<13 && n!=9)) cout<<"-1\n"; else{ if(n%2!=0){ n-=9; f++; } f+=(n/4); cout<
 » 14 months ago, # | ← Rev. 3 →   0 wait whoops i forgot to flush output for final answer for B and i still passed pretests even though the problem warns against this, i hope i pass systest...EDIT @below: Nope, I used '\n' to end my line, I really hope I'm okay...
•  » » 14 months ago, # ^ |   0 is it necessary to flush out??
•  » » 14 months ago, # ^ | ← Rev. 2 →   0 maybe you used endl , it calls os.flush()
 » 14 months ago, # |   0 Hacks for C?
•  » » 14 months ago, # ^ | ← Rev. 2 →   0 I don't know which ones where in pretests, so I'll write some special cases:559111315
 » 14 months ago, # | ← Rev. 4 →   +59 Fun solution for Div.1 D:The main observation is that the distance for every pair is either 0, 1, 2 or 3.You can easily find the number of pairs with distance 1 (they have gcd ≠ 1 and this is a well known problem).For the number of pairs with distance 2 the following condition should be true:lp(X) * lp(Y) <  = n, where {X, Y} is the pair (lp(x) here is the least prime divisor of x).That's true, because we can have a path like X -> (lp[x] * lp(y)) -> Y.And now we are left with pairs with length 3. The following conditions should be true:lp(X) * lp(Y) > n and max(lp(X), lp(Y)) * 2 <  = n, where {X, Y} is the pair.That's true, because we can have a path like X -> (2 * lp[x]) -> (2 * lp(y)) -> Y.Well if we have found the number of pairs of distance 2 and we count the number of pairs for which max(lp(X), lp(Y)) * 2 <  = n is true and then remove the number of pairs with distance 2 we will get the number of pairs with distance 3.Well now the only part is how to count the number of pairs with the given two conditions. We can do a fenwick tree on the values. Here is the code.
•  » » 14 months ago, # ^ |   0 Why is distance being further than 3 impossible?
•  » » » 14 months ago, # ^ |   +20 Because for every pair {X, Y} if there is a path, then we can go like X -> (2 * lp[x]) -> (2 * lp(y)) -> Y.
•  » » 14 months ago, # ^ |   0 Could you explain how you count these pairs with a fenwick tree a little more? Maybe it's less complex than I'm making it out to be, but I got the conditions in-contest but couldn't figure out how to count them easily.
•  » » » 14 months ago, # ^ | ← Rev. 2 →   +18 First we do n - 1 point updates of form add 1 to lp(i).Now we start iterating all numbers from 2 to n. Let our current position/number be i. We remove 1 from the fenwick tree at position lp(i). Now the number of pairs with lp equal to X is the value at position X in the fenwick tree. To count the number of positions lp(X) * lp(Y) <  = n we can simply query the range [2;n / lp(i)]. For the second condition (lp(X) * lp(Y) > n and max(lp(X), lp(Y)) * 2 <  = n) we will have query in range [2;n / 2] — query in range [2;n / lp(i)]. And we only add the second part to the answer (the pairs with distance 3) if 2 * lp(i) <  = n.
•  » » » » 14 months ago, # ^ |   0 What does cnt[i] calculate in your code?
•  » » » » » 14 months ago, # ^ |   0 Initially the number of numbers divisible by i. Then the number of pairs of numbers with gcd equal to i.
•  » » » » » » 14 months ago, # ^ |   +44 Ok I finally got the key part I've been missing , namely the fact that if x and y are distinct, not coprime and at most n then the product of the smallest prime factor of both numbers must be at most n. Proof : Let g be the gcd, then if g does not exceed sqrt(n) we're done. Otherwise, let x = ga, y = gb, and wlog b > 1. Then, the product of smallest prime divisors is at most gb which is at most n.
•  » » 14 months ago, # ^ | ← Rev. 4 →   +10 I don't think we need BIT here.To find the number of pairs for which lp(i) * lp(j) <= n, just store the prefix frequencies of the lp array. Then for every i, add pref[n / lp[i]]. Remove the number of i, such that lp(i) * lp(i) <= n, and divide by 2.Link
•  » » » 14 months ago, # ^ |   0 You're right. Idk why I didn't see that.
•  » » 14 months ago, # ^ |   +13 Thank you for this solution. I would like to add that it can be adapted to O(n) by using two pointers instead of Fenwick trees. Code : 31374591
 » 14 months ago, # | ← Rev. 3 →   0 Does any one solved problem div2 C using DFS / BFS or Recursion or dp ?
•  » » 14 months ago, # ^ | ← Rev. 2 →   +6 I used greedy: keep subtracting 4 from the number. If n % 4 == 1: Use 9 as your composite number. If n % 4 == 2: Use 6 as your composite number. If n % 4 == 3: Use 15 as your composite number. This is the rough idea behind the problem.
•  » » » 14 months ago, # ^ |   +2 you mean use 6 and 9 as composite numbers if n%4==3
•  » » » » 14 months ago, # ^ |   +5 Yes, my bad. :P I did assign a count of 2 to 15, so my final answer is fine.
•  » » » 14 months ago, # ^ |   0 I tried solving it using recursion , got TLE @test case 7
•  » » » » 14 months ago, # ^ |   +6 The number can be up to 10^9. What did your recursion do, exactly?
•  » » » » 14 months ago, # ^ |   0 i solved using dp. Greedy till certain point ( ~5000), dp in the end.
 » 14 months ago, # |   +5 May be rename to Mathforces?
•  » » 14 months ago, # ^ |   -8 Haha , i am new to this platform . I tried Memoization and DFS for problem C.Now people are saying to us only 6 and 9 as composite number :|.
 » 14 months ago, # | ← Rev. 3 →   +5 For some reason, for Div 2 C I thought that the queries themselves had to be prime to be valid, and I would need to print out -1 if the queried number wasn't prime. I wrote up the entire code of getting all the primes less than sqrt(1 billion) by checking for primality with a sieve. Then I checked for each query number if it was not prime by seeing if it could be divided by any of these prime numbers < sqrt(1 billion) I found through the seive, and then I realized I had interpreted the problem wrong and had added more requirements than necessary!
•  » » 14 months ago, # ^ | ← Rev. 2 →   0 Anyway, how did you check primality of numbers up to 1e9 using sieve, not miller-rabin?
•  » » » 14 months ago, # ^ | ← Rev. 2 →   0 I found all the prime numbers less than sqrt(1e9) using a sieve. There were about 5,000 or so I think.I stored all these primes in a vector.And to check whether each queried number N was prime, I just iterated through the primes and checked if any of them could divide N.This would come out to about 5 * 1e8 time.
•  » » » » 14 months ago, # ^ |   0 Thanks. An offline method, interesting :)
 » 14 months ago, # |   -11 waiting for system test.
 » 14 months ago, # |   -6 When will the system test start?
 » 14 months ago, # | ← Rev. 2 →   +434 Come on, khadaev. We agreed to submit on 1:30 -_-
•  » » 14 months ago, # ^ |   -7 cheaters xD
 » 14 months ago, # |   +5 How to solve div.2 D? It's it about circles of permutation?
•  » » 14 months ago, # ^ |   0 It's about n^2 brute-force. You can query (0..n-1, 0) and (0,0..n-1) and try every position of b0, say fix b0=i.Then reconstruct p from pi=b0^(saved query(i, 0) value). Finally, check whether it is a valid permutation and consistent with the queries.
•  » » » 14 months ago, # ^ |   0 Er...set b0 to i?Are you mean that assume b0 is i,then Query(0,0-n-1) and Query(0-n-1,0)...?It seems good...But how to construct all the p values or determine the value of the true b0...?Sorry for my late reply and my low intelligence...
•  » » » » 14 months ago, # ^ | ← Rev. 6 →   0 Let Q0, Q1 be arrays of length N and Query(X, Y) be query value — i.e. P[X] xor B[Y].We can save Q0[i] = Query(i, 0) and Q1[i] = Query(0, i) for all 0<=i
 » 14 months ago, # | ← Rev. 2 →   0 I think div.2E is a problem of combination number,but I can't get the solution.
 » 14 months ago, # | ← Rev. 3 →   0 Div.2D: I wrote all my queries to stdout and flushed, then read the all of the answers one by one, and my submission got an ILE? Somebody wrote one query to stdout and then read the answer at once, then he passed the pretest? Is it my fault? My Submissions:cstdio versioniostream versionPractice submission(query and then read at once):Practice version
 » 14 months ago, # | ← Rev. 4 →   +4 del
•  » » 14 months ago, # ^ |   0 На прошлом раунде взяли 100 человек, так что еще неизвестно )
 » 14 months ago, # | ← Rev. 3 →   0 I submitted solution to B after hack to my solution which got accepted. To recheck it i submitted my previous solution again and it showed the wrong answer. Now my solution (correct one) is not getting evaluated. Will they not consider my correct solution. :( EDIT : They evaluated it :)
 » 14 months ago, # | ← Rev. 3 →   +5 NOOOOOOOOO!!!!!!!In Div2 D During the contest I read the answer of 2*n times together and I got an ILE…… After contest I tried read every answer after questioning I got AC …… Oh my goodness……
•  » » 14 months ago, # ^ |   0 Same thing happened to me, which wasted me 30 minutes and 7 incorrect submissions = almost 500 points.
 » 14 months ago, # | ← Rev. 2 →   +9 How to solve Div.1 E?
•  » » 14 months ago, # ^ |   +16 I think the main problem is constructing compressed tree for that k vertices. I remember it is to solve this: https://open.kattis.com/problems/optimistan.
•  » » 14 months ago, # ^ |   +16 Pick a pair of special vertexes U,V that are as far from each other as possible. Construct a chain that connects them (these are the points with d(U,W)+d(W,V)=d(U,V) ordered by distance from U). Consider subtrees rooted at each vertex from this chain. We can easily split all vertexes into these subtrees. The distances to each vertex X from X's root Y equals to d(U,X)-d(U,Y). So we may treat roots as special vertexes. Most of subtrees will have only one special vertex — the root. They may be processed in O(N) in total. For the other subtrees we recursively call the same procedure.This process seems to terminate quickly. On every step each subtree will lose 2 special vertex, but it may possibly generate some new. The more subtrees there are, the faster the special vertexes are lost. It seems all vertexes will be processed in O(K) iterations and problem is solved in O(KN).
 » 14 months ago, # |   0 Good, lucky problems, good contest as well as author!
 » 14 months ago, # |   +45 My screencastHope you find it interesting!
 » 14 months ago, # |   0 For problem B for k==2 how is it max(a[0],a[n-1])
•  » » 14 months ago, # ^ |   0 Seeing, that you can achieve it, is pretty easy. You can take that one element as one segment, and the rest as the other. Let's assume we achieve an answer x such that x > max(a0, an - 1). If this element is in the first segment, then the first segment's value should be x, but since x > a0 the score will be at most a0. Same goes for the second segment, so x can be in neither segment, which is contradiction.
•  » » 14 months ago, # ^ |   0 Splitting of array a of n elements into 2 subarray，it must be a prefix and a suffix. for the minimum to be larger, we make the 2 subsegments [0,n-2] and [n-1, n-1] or [0, 0] and [1,n-1]
•  » » » 14 months ago, # ^ |   0 subsegment can be:[0,n-3][n-2,n-1] like that...why these two??
•  » » » » 14 months ago, # ^ | ← Rev. 2 →   0 2 subsegment : [0, x], [x+1, n-1] (0 <= x < n-1)the answer is max(mininum in [0, x], mininum in [x+1, n-1])so :mininum in [0, 0](it is a[0]) is larger than mininum in [0, x]mininum in [n-1, n-1](it is a[n-1]) is larger than mininum in [x+1, n-1]when a[0]>a[n-1] a[0] is larger than mininum in [0, x] and mininum in [x+1, n-1](for each x : 0 <= x < n-1)when a[0]
•  » » 14 months ago, # ^ |   0 in this case : for the most right element : if you go to the left and added elements to the segment that contains the Nth element you have 2 probabilities : either add greater element and this doesn't affect the answer , or add smaller element and this is a wrong step. for example , consider these numbers : 1 2 4 9 8 start your segment from the most right and add the element 8 , adding 9 doesn't maximize the answer (no change ) , adding 4 will reduce the previous answer and this is wrong step. the same for the most left element. so you have to choose the maximum between them.
 » 14 months ago, # |   0 Oh..There are so many hacks today! You see There are about one thousand and seven hundred people solved ABC during the contest. So do I. But my solution for B got a FST... Because I defined the mininum by -1e9+7 instead of -(1e9+7).. But I still got rank 180..Because I hacked eleven people :P
 » 14 months ago, # |   +10 Will there be an editorial?
 » 14 months ago, # |   0 http://codeforces.com/contest/872/submission/31353320check this solution for Div2D.When something likes "5000 xor 4191" happens, will it get Runtime Error ? I think it willbut why it didn't happen ?
•  » » 14 months ago, # ^ |   0 I think you don't need to do this. I'm just lucky. :)
 » 14 months ago, # |   +3 Is the editorial published ?
 » 14 months ago, # |   0 How you guys came up with Div2-C . I mean is it writing bruteforce than generalizing it Or there is some other way to approach for solution?
•  » » 14 months ago, # ^ |   +6 I will try to explain a possible approach.First, if you want to represent n as a sum with lots of summands, those summands have to be small. Therefore you should ask yourself, what is the smallest suitable summand? It is 4. Can you use only 4? Only if n % 4 == 0. What about the other remainders modulo 4? You are obliged to use something else apart from 4. The next composite number is 6. You can see that if n % 4 == 2, using one 6 and all 4 is optimal. But you cannot obtain any odd n using only 4 and 6. Hence you need to use one more number. Maybe 8? No 8 is not useful as 4+4=8. Maybe 9? Yes! Using one 9 and all 4 you can obtain all n % 4 == 1.The only remaining case is n % 4 == 3. Can you get it using only 4, 6, 9? The answer is yes as 6 + 9 % 4 == 3. The issue is that this is no more trivially optimal and you have to check the optimality. However, checking it is super-easy, as the smallest useful number (i.e. it is composite and it cannot be generated as a sum of 4, 6, 9) is bigger than 6+9 = 15 and therefore using 6+9 is optimal if n % 4 == 3.p.s. I have ignored all small cases. As a byproduct of the explanations I have given ,those are all impossible (1, 2, 3, 5, 7, 11).
•  » » » 14 months ago, # ^ |   0 That's very helpful. Thanks a lot :)
 » 14 months ago, # |   +6 And how many participants went to the final?
 » 14 months ago, # |   0 Does anybody know why I receive "Denial of judgement" for sources 31428657 and 31428722 ? The error on test 88 is : Can't compile file: Compilation process returned error: execution failed because of unknown invocation error