### PikMike's blog

By PikMike, history, 9 days ago, translation, ,

Hello Codeforces!

Series of Educational Rounds continue being held as Harbour.Space University initiative! You can read the details about the cooperation between Harbour.Space University and Codeforces in the blog post.

This round will be rated for the participants with rating lower than 2100. It will be held on extented ACM ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.

You will be given 7 problems and 2 hours to solve them.

The problems were invented and prepared by Roman Roms Glazov, Adilbek adedalic Dalabaev, Vladimir Vovuh Petrov, Ivan BledDest Androsov, Grigory V--gLaSsH0ldEr593--V Reznikov and me.

Good luck to all participants!

Congratulations to the winners:

Rank Competitor Problems Solved Penalty
1 krijgertje 7 182
2 dreamoon_love_AA 7 191
3 KrK 7 196
5 palayutm 7 217

Congratulations to the best hackers:

Rank Competitor Hack Count
1 _bacali 457:-133
2 MarcosK 252:-6
3 nikit523 129:-6
4 greencis 139:-29
5 djm03178 68:-3
1967 successful hacks and 1152 unsuccessful hacks were made in total!

And finally people who were the first to solve each problem:

Problem Competitor Penalty
A bazsi700 0:00
B sorry_stefdasca_snsdsux 0:04
C bazsi700 0:07
D Yuki_Matsui 0:17
E 504 0:03
F krijgertje 0:48
G RUSH_D_CAT 0:11

•
• +212
•

 » 9 days ago, # |   +197 Uhh, can't wait til BledDest, Roms and Vovuh finally get rid of their new year colors!
•  » » 9 days ago, # ^ |   +260
•  » » 9 days ago, # ^ |   0 Is this comment of yours an intended one to troll not-PikMike? :thinking:
•  » » 9 days ago, # ^ | ← Rev. 2 →   +75 Every New Year, most of the codeforces community be like. xD
•  » » » 8 days ago, # ^ |   -27 Anyways, I topped the Rating and Contribution Rank! (In this photo) ;)
•  » » » » 8 days ago, # ^ |   +11 Who cares
 » 8 days ago, # |   +13 PikMike has been problem settler over 50 contest, it's even more than number of contests I've ever participated. Where those problems come from?
•  » » 8 days ago, # ^ |   +41 All of them are from the other members of our team. I prepared lots of problems, however, I only own like 5 ideas of all those contests. The truth hurts!)
•  » » » 8 days ago, # ^ |   +17 Well, not all of these problems are ours. Sometimes participants send their ideas about problems, and we prepare them. There are also some problems that are taken from training camps and slightly modified (or even not modified); it was a bit common in some earlier rounds, but now we are trying to avoid such problems (it is not always possible, though).
•  » » » 8 days ago, # ^ |   +25 Any way thank you for Educational rounds. ;)
•  » » 8 days ago, # ^ |   -28 Google)
 » 8 days ago, # |   0 Ctrl A Ctrl C Ctrl V Compile Activated
 » 8 days ago, # |   +30 Is PikMike MikeMirzayanov, since PikMike didn't thank him?
 » 8 days ago, # |   -60 The worst educational round ever!
 » 8 days ago, # |   -15 Weak pretests, my solutions passed >:(
•  » » 8 days ago, # ^ |   +55 Pretests might be weak but you are weaker. You would've found them if you solved G.
•  » » » 8 days ago, # ^ |   0 :((((((
 » 8 days ago, # | ← Rev. 2 →   +11 it's weird if E is that easy :P maybe that's new year gift from santa PikMike or something
•  » » 8 days ago, # ^ |   0 SupaHotFire just comment out the fast input and submit again
•  » » » 8 days ago, # ^ |   0 lol !! it would give TLE then
•  » » » 8 days ago, # ^ |   0 Wow man, I got a TLE on 7 when I removed FIO :O
 » 8 days ago, # |   0 Almost spent an hour implementing segment trees for E, because I thought "an E-graded problem can't be easier than that, right?". Yes, I'm newer around here.
•  » » 8 days ago, # ^ |   +1 I though the same but after seeing the number of submissions,figured it was probably easy.
•  » » 7 days ago, # ^ | ← Rev. 2 →   0 In problem C, I had done sorting of pairs in asscending order and then checking it belongs to which group gives WA on test 3. like this:for(int i = 1; i < n; i++){ if(v[i].fi > v[i-1].sec){ ans[i] = 1-ans[i-1]; // swapping grp from 1 to 0 or 0 to 1. } else{ ans[i] = ans[i-1]; //keeping it same. } }can someone tell me the correct approach for it?
•  » » » 7 days ago, # ^ |   +6 you have to keep track of max right in current group then compare.
•  » » » » 7 days ago, # ^ | ← Rev. 2 →   0 I did the same wrong, but initially got corrected! :)
•  » » » 7 days ago, # ^ | ← Rev. 2 →   0 Consider this test: 3 1 10 3 4 5 6 
•  » » » » 7 days ago, # ^ |   0 It answer is -1, right?
•  » » » » » 7 days ago, # ^ |   0 Yes, it is
 » 8 days ago, # |   +3 So how do you solve F if binary search + greedy is too slow?
•  » » 8 days ago, # ^ |   +18
•  » » » 8 days ago, # ^ |   +14 We thought that there would be a lot of solutions with this technique, but to our surprise more people solved it with three-dimensional DP instead.
•  » » » 8 days ago, # ^ | ← Rev. 2 →   0 I've thought about this too. Does the greedy work though? For the sample test my solution gets 203, which is wrong. P.S. My code: 48258662
•  » » » 8 days ago, # ^ |   0 Wow, that seems like such a simple trick in hindsight. I'll try not to forget it. Thanks!
 » 8 days ago, # |   0 How to solve problem G? I could only figure out that the answer must be less than 30.
•  » » 8 days ago, # ^ | ← Rev. 6 →   +19 This is some of my ideas for problem G (I hope it wasn't totally correct because I did not finish coding it :( ) :1, Calculate the prefix sum array fi2, Represent each fi as a binary vector.3, Calculate the dimension of the vector space spanned by the vectors that I found in Step 2. If the dimension is 0, print out -1, otherwise print that dimension.We also need to check if fn is an element of some basis.
•  » » » 8 days ago, # ^ |   0 check if f[n] is an element of some basis is just checking that f[n] != 0, right?
•  » » » » 8 days ago, # ^ |   0 Yes
•  » » » » » 6 days ago, # ^ | ← Rev. 3 →   0 Ty
•  » » » » 8 days ago, # ^ | ← Rev. 2 →   0 Yeah.I'm interested in the proof that checking all prefixes is sufficient, though. I couldn't prove it. :/
•  » » » » » 8 days ago, # ^ |   +9 Let's say you have 3 valuesb[1], b[2], b[3]Also, c[1] = b[1], c[2] = b[1] ^ b[2], c[3] = b[1] ^ b[2] ^ b[3]Every possible subset of c's correspond to a unique subset of b's (and vice-versa) so it's the same thing if you take the xor of segments or prefix xor until the end of the segments.
•  » » » » » » 8 days ago, # ^ |   0 Thanks!
•  » » » » » » 7 days ago, # ^ | ← Rev. 2 →   0 Won't finding basis using gaussian elimination take O(32*32*N) time? but it still runs fast, I have just learned about Gaussian elimination so I am curious why it runs fast?! Also , it seems intuitively true that answer will be basis, but how can we prove it?!
•  » » » » » » » 7 days ago, # ^ |   0 32 * N because you can use bitwise operations (xor). If the numbers are all linearly independent, then there's no subset that xors to 0 so this is the necessary and sufficient condition to be a valid set of segments. Also, every number different from 0 can appear in the answer (just start adding it first). The prefix xor stuff I explained above.
•  » » » » » » » » 7 days ago, # ^ | ← Rev. 2 →   0 If we are asked to give one such division of max number of segments, then we will make division at the positions where we get prefix xor as a new basis element.If ever a segment has xor zero, we need to add some elements from its right or left.. Is it correct..?
•  » » » » » » » » » 7 days ago, # ^ |   0 First part is correct. Second part is useless since when you add a 0 it won't be added as new element. The only detail is that you'd need to add elements from right to left to make sure that the last element is in the answer.
•  » » » » » » » » » 7 days ago, # ^ |   0 Got it.. Thanks..!!
 » 8 days ago, # |   -9 Is it just me? I got TLE in Problem E, this is my solution. https://codeforces.com/contest/1101/submission/48246073After scratching my head for some minutes, I added ios_base::sync_with_stdio(false); cin.tie(NULL); And voila, it passed.
• »
»
8 days ago, # ^ |
-21

# metoo

•  » » 8 days ago, # ^ |   -10 i got TLE till the end. fml need to learn cpp now.https://codeforces.com/contest/1101/submission/48253797
•  » » » 8 days ago, # ^ |   +5 sys.stdin.readline() instead of input() and using PyPy instead of Python speeds up this solution greatly.
•  » » » » 8 days ago, # ^ |   0 well i did as you said got a WA on test case 10 thanks but idk why i am getting WA. My algo seems correct
•  » » » 8 days ago, # ^ |   0 You can apply fast IO in python too !
•  » » 8 days ago, # ^ |   -10 Yeah..What was that, i mean because of that i got 2 penalties.
•  » » » 8 days ago, # ^ |   +3 lets see what PikMike replies to this
 » 8 days ago, # |   +10 I brainfarted so hard this contest and i am really disappointed of myself... Solved A in 2 minutes then nothing... I didn't know how to solve B even though i think it's really easy (even tried to implement a DP solution) and i thought for one hour and a half that C was asking something else... RIP my ratingF for prayers
•  » » 8 days ago, # ^ |   +9 F
•  » » » 8 days ago, # ^ |   +12 I literally thought i had to print the number of characters i eliminated.Kill me
•  » » » » 7 days ago, # ^ | ← Rev. 2 →   +1 NO — SUFFEЯ UPD: well, we all have blunders, which are especially humiliating if you slip while reading the task spe. I've just had the same experience with A (I misunderstood it two times, hence spent 15 minutes instead of 3 or maybe 5)... so yes, I am SUFFEЯing here with you, haha
•  » » » » 7 days ago, # ^ |   0 ohhh, so that's why, after trying so hard with the B and didn't know wtf is going on, you saved my day m8 :x
 » 8 days ago, # | ← Rev. 2 →   0 Does greedy with binary search work for F? I got a TLE on 23rd test.
•  » » 8 days ago, # ^ |   0 Binary-search can't pass timelimit!
•  » » 8 days ago, # ^ |   +5 shuffle the array randomly first
•  » » » 8 days ago, # ^ |   0 Can you elaborate on which array to shuffle? We need to maintain contiguity in cities right?
•  » » » » 8 days ago, # ^ |   +15 The Trucks Array should be shuffled randomly,and while doing binary search on each truck you should maintain the highest fuel size found,if this fuel size is good enough for the current truck, you shouldn't do binary searchshuffling just increase the chance of getting the highest fuel quickly.
 » 8 days ago, # |   -14 PikMike https://codeforces.com/contest/1101/submission/48242640 https://codeforces.com/contest/1101/submission/48241968 the only difference is fast input line i dont think thats how you decide the outcome of a question
•  » » 8 days ago, # ^ | ← Rev. 2 →   -11 a
•  » » 8 days ago, # ^ |   -11 https://codeforces.com/contest/1101/submission/48253797my python implementation.it won't pass
•  » » 8 days ago, # ^ |   -9 https://codeforces.com/contest/1101/submission/48246817 https://codeforces.com/contest/1101/submission/48247813 Exact same code but TLE on one.
•  » » 8 days ago, # ^ |   -28 So this round should be unrated right?
 » 8 days ago, # |   +3 what can be the test case 4 of problem C ?
•  » » 8 days ago, # ^ |   +3 42 33 46 77 8Ans — 1 1 2 2
 » 8 days ago, # | ← Rev. 2 →   +1 Well, idk if I was tired or whatever, but B seemed really hard to me, maybe one of the hardest B's ever imo.
•  » » 8 days ago, # ^ |   0 Think of it simply and greedy, you will figure out that we should find first "[...:" and last ":...]" of the string which satisfy two ':' are different, then just choose all '|' between two ':'.
•  » » » 8 days ago, # ^ |   0 I have AC, it just happened that I found it extremely hard.
 » 8 days ago, # | ← Rev. 3 →   0 I had to spend more than an hour solving problem C. That is a very annoying type of problem. I finally solved problem C, but Spending too much time is the cause of trouble. I couldn't submit the Accepted code by a few seconds, so I couldn't solve problem E in the competition. :(
•  » » 8 days ago, # ^ |   +4 Same happened with me.Completely forgot to check dashboard while solving C ,otherwise i could have solved E
•  » » » 8 days ago, # ^ |   +1 And within one minute after System Testing was finished, I submitted the correct code...
•  » » » » 8 days ago, # ^ |   0 i know ,code was too short.There was nothing in this problem to put as problem E but still badluck !!
•  » » » » » 8 days ago, # ^ |   0 can you explain me why my E got TLE at test 7 please :< https://codeforces.com/contest/1101/submission/48241159
•  » » » » » » 8 days ago, # ^ | ← Rev. 2 →   0 I had the same issue Add these ios_base::sync_with_stdio(false); cin.tie(NULL); 
•  » » » » » » » 8 days ago, # ^ |   0 ohh..thank you so much ! i get AC now
 » 8 days ago, # |   -25 PikMike Check out these two submissions 48241968 48242640 The only difference is that i have commented the fast input line in one of them without fast input it gives TLE in tc7 while gives AC with fast input I dont think thats a wise way to judge a question these question must check the logic not fast input and you could have written in the question that fast input may be necessary
•  » » 8 days ago, # ^ |   -24 I am not alone many others have also faced this issue
•  » » » 8 days ago, # ^ |   0 yup....i know python sucks but never knew this much....i am new to this platformhttps://codeforces.com/contest/1101/submission/48253797 PikMike Take a look at my solution
 » 8 days ago, # |   0 How to solve C?
•  » » 8 days ago, # ^ |   0 I solved it by finding the non intersecting segments in the union of all the given segments. After that just put the first segment in one of the group and all others in the second group.
•  » » » 8 days ago, # ^ |   0 i did the same..but i cant understand why i got a wrong answer
•  » » » » 8 days ago, # ^ | ← Rev. 3 →   0 Check this Test.42 33 46 77 8Ans — 1 1 2 2
•  » » 8 days ago, # ^ | ← Rev. 2 →   +1 Sort segments by L. Put segment 0 in group 1 (set t[0] = 1). Also, let r = R[0] (right border of segment 0). Now, for segments 1 to n-1: if L[i] <= r, we must put it in group 1 (t[i] = 1), also r = max(r, R[i]), as we are continuing the group. Otherwise (L[i] > r), put it and all others to its right into group 2. Note: for simplicity's sake I wrote t[0], t[1] etc, but since you sort the segments this won't work. There is a simple workaround to this, though.
 » 8 days ago, # |   0 Ugh, I saw that F was solved by almost no one so I only decided to read it 10 minutes before the end of the contest, realized that it was really easy and ACed it 5 minutes after contest... RIP rating
•  » » 8 days ago, # ^ |   0 binary is tle
•  » » » 8 days ago, # ^ |   +9 Well...
•  » » » » 8 days ago, # ^ |   0 Oh, nice. My bad.
 » 8 days ago, # |   +20 That moment when E has more AC than C
 » 8 days ago, # |   0 Can anyone help me understand what i did wrong for question c. what i basically did was a brute force approach,checked if a number(point) is occurring in other segments if not i am marking that index and then printing 2 for other segments and 1 for the marked index. my sol is here
•  » » 8 days ago, # ^ | ← Rev. 2 →   0 I think you misunderstood the problem.
•  » » » 8 days ago, # ^ |   0 can you give me any test cases?? The test case for which my code went wrong is not being shown.
•  » » » » 8 days ago, # ^ | ← Rev. 2 →   0 The "segments" the problem is referring to contains all integers from l to r. For example, for this case: 2 1 3 2 4 The two segments intersect, therefore the answer should be -1.
•  » » » 8 days ago, # ^ |   0 Thought about the intersection part and understood my mistake!!!
•  » » » » 8 days ago, # ^ |   0 That's great. But also, you should not expect an O(n^2) solution to pass anyways.
•  » » » » » 8 days ago, # ^ |   0 Given the time limit and due to my misunderstanding i tried the O(n^2) approach.i mostly code on codechef and a 2 sec time limit generally implies a brute force will pass..
•  » » » » » » 7 days ago, # ^ |   0 No. Never does so. It depends on constraints. If n <  = 103 then only it passes on codechef. If constraints are as big as 105 on codechef then O(nlogn) solution may pass.
 » 8 days ago, # |   0 A better version of problem E would be to find the number of bills inside the wallet for each query.Solution: Click hereTime Complexiy: O(Nlog^2N)Space Complexity: O(NlogN).Any better solution?
•  » » 8 days ago, # ^ |   0 this got TLEbut it is O(n) i guess.....yeah its python it sucks will never use again i was new here
•  » » » 8 days ago, # ^ |   0 Compile with PyPy, not Python
•  » » » » 8 days ago, # ^ |   0 tried that too still got a TLE https://codeforces.com/contest/1101/submission/48252504
•  » » 8 days ago, # ^ |   0 Lol what an overkill for E. Nice
•  » » » 8 days ago, # ^ |   0 can u please help me as why did i get a TLE???
•  » » » » 8 days ago, # ^ |   0 Complexity is good, just, python is slow in this one. Try to maybe find some function for optimizing input idk.
•  » » 8 days ago, # ^ |   0 yeah did it in O(n).check my sol.
•  » » 8 days ago, # ^ |   0 I tried to implement it like this but didn't manage to make it fit the time limit, even with all optimizations. It gets to test 24 (and it seems really close).
 » 8 days ago, # |   0 i got TLE till the end. fml need to learn cpp now.
•  » » 8 days ago, # ^ |   0 use ios_base::sync_with_stdio(false);cin.tie(NULL); after doing E got the importance of
 » 8 days ago, # |   +1 How to solve D?
•  » » 8 days ago, # ^ |   +5 For each prime p find vertices that p | a[i], and find max path in every component of graph consisting of vertices you found.
•  » » » 8 days ago, # ^ |   0 Can you please elaborate? After finding the vertices that divide a particular prime what do we do? What is the component that you are talking about?
•  » » » » 8 days ago, # ^ |   0 I mean if you only take the vertices from graph that can be divided by p, graph will get divided into some components, take max path from each component.
•  » » » » » 8 days ago, # ^ |   +1 Alright I understand the logic thanks a lot!Can you still explain how did you implement it? I mean how did you divide the graph into only the components with these vertices.After getting the above I'll be able to solve it with DFS
•  » » » 8 days ago, # ^ |   0 Will it fit in time limit?
•  » » » » 8 days ago, # ^ |   0 There can be only 7 unique primes that divide every number, so it's O(N).
•  » » » » 8 days ago, # ^ |   0 I think so. The sum of all sizes of the graphs will be O(n log n), because each vertex has at most O(log n) prime divisors.
 » 8 days ago, # |   0 Educational are now nightmares...RIP rating.. Hope for good Div 2.. How to solve C?
 » 8 days ago, # |   0 Why are there so many problems for which the query is given?
 » 8 days ago, # |   0 C condition is very strenge,i have solved the problem where it is asked to divide the set of segments into two sets such that each set does not have overlaps
 » 8 days ago, # | ← Rev. 2 →   0 Why does my submission for C fail in tc1 using g++ 11/17 48256069&& gets AC with clang 48258190 ? Edit : I figured it out i wrote the fast io thing after doing the first cin
•  » » 8 days ago, # ^ |   0 Replace if(!j) by if(j).
 » 8 days ago, # |   +3 Problem D Code Can someone please tell what's wrong in this code?
 » 8 days ago, # | ← Rev. 2 →   -7 Good contest!
 » 8 days ago, # | ← Rev. 3 →   0 In Problem C, I first Sort the interval according to x and then y. Then I traversed and check while(arr[i].y >= arr[j].x) j++. I put them into same set.Here is my implementation (Link) why it is giving WA??? can anyone give me by giving a useful test case.
•  » » 8 days ago, # ^ |   +1 testcase : (1,9) (2,3) (4,5)
•  » » » 8 days ago, # ^ |   0 Thanks a lot.
 » 8 days ago, # |   +4 What are the prerequisites to solve G? And please can anyone suggest relevant resources for the same?
•  » » 8 days ago, # ^ |   +22 https://math.stackexchange.com/questions/1505293/how-many-subsets-xor-to-given-valueGaussian elimination on binary vectors. This kind of problem appeared many times before, even in educational rounds.
•  » » » 8 days ago, # ^ |   0 Thanx a lot!!
 » 8 days ago, # |   +67 I don't see any issue with the amount of the input data in E. It is totally fine to remind you to use faster i/o operations once in a while. My solution works in 300ms and I set TL for 3s. That is so generous that you can even get AC in Python (if you know how to read data fast there). There is no difference between getting TL because of slow i/o and because of unoptimal solution. And you shouldn't blame author for failing slow solutions.
•  » » 7 days ago, # ^ |   +6 Is there any reason for setting that problem as problem E though? There is a fastio trap, but that should not raise the problem difficulty that much.
 » 8 days ago, # | ← Rev. 2 →   0 thanks for good contest .I was surprised to see problem e is easier than b and c.
 » 8 days ago, # |   +28 Cheaters J3far , timo14z On all Problems : DI hope you look into it PikMike.
•  » » 8 days ago, # ^ | ← Rev. 4 →   -6 they will probably be skipped wether you say it or not.
•  » » 8 days ago, # ^ | ← Rev. 2 →   +21 it's a shame that a former contest writer is doing this
•  » » » 7 days ago, # ^ |   0 you are right
 » 8 days ago, # | ← Rev. 2 →   0 How to optimize this solution for F. I used randomization but I have TLE on test 23
 » 8 days ago, # |   +1 after doing E got the importance ofios_base::sync_with_stdio(false);cin.tie(NULL);
•  » » 8 days ago, # ^ |   0 ya bro u r right!!!! xD:
 » 8 days ago, # |   0 Can someone help with this? Getting WA on 23rd testcase. TIA.https://codeforces.com/contest/1101/submission/48256109
 » 8 days ago, # |   +6 What's going on with the hacks on E? Is the hack making the solution TLE because of the slow input?
 » 8 days ago, # |   +14 How to solve G
•  » » 8 days ago, # ^ |   +3 add these lines:ios_base::sync_with_stdio(0); cin.tie(NULL);
 » 8 days ago, # |   +2 Do hacks give points??
•  » » 8 days ago, # ^ |   +8 Not in educational or Div3. But gaining top position in Hackers Table is prestigious.
•  » » » 7 days ago, # ^ |   +8 Besides, if you make more hacks, you can get a higher ranking since others drop.
 » 8 days ago, # |   +4 I solved E faster than B.. :/
•  » » 8 days ago, # ^ |   0 I solved D faster than C :)
•  » » » 8 days ago, # ^ |   +59
•  » » » 8 days ago, # ^ |   +1 Can u please tell the logic to solve D?
•  » » » » 8 days ago, # ^ |   0 Please refer this. :)
 » 8 days ago, # |   0 How to solve C?
•  » » 8 days ago, # ^ | ← Rev. 2 →   +1 Sort all the queries wrt left limit li. Then traverse keeping track of the max of right limit ri, let us assume rmax. If u ever get l(i+1) > rmax at ith iteration, u can divide it into two groups.
 » 8 days ago, # | ← Rev. 2 →   0 Hi everyone! Could someone help me? I tried to solve problem C, but it gives me TLE and my computer runs the first test case in 31 ms. :( This is my submission.
•  » » 8 days ago, # ^ |   0 As there are many test case, try to clean vectors only if they are less than or equal n, not maxn.
 » 8 days ago, # | ← Rev. 2 →   +45 Here's a spoiler for my 60 hacks on E: As already mentioned above, the amount of input is quite large. Though some solutions using endl or alternating cin and cout still passed, reaching ALMOST 3s.There was also a test where 499999 queries are '?' queries so it was an 'almost-worst case' for such solutions. But it wasn't 'THE worst' case.I made a generator where the first query is + 1000000000 1000000000 and the rest 499999 queries are ? 1000000000 1000000000. This input not only consists maximum number of characters possible, but also requires maximum number of characters in the output. Then I just went through every AC submissions with time > 2900ms and it worked for all of the 'slow-I/O' codes.
•  » » 8 days ago, # ^ |   0 isnt the hack file too large to be submitted as testcase?
•  » » » 8 days ago, # ^ |   +5 One can generate the input by writing a generator code.
 » 8 days ago, # | ← Rev. 2 →   +9 Little overkill I made on problem D .. :) I used Centroid Decomposition!!https://codeforces.com/contest/1101/submission/48257605
•  » » 8 days ago, # ^ |   +3 Me too. xd
 » 8 days ago, # | ← Rev. 2 →   +24 Im GENIUS!!! Im hacked all people, who solved problem B on PascalABC... INCLUDE ME..IM SUPER GENIUS...!!
 » 8 days ago, # |   0 haha so glad i skipped this one see the people getting hacked off:))))))))))))))=)))))))))
 » 8 days ago, # | ← Rev. 2 →   +4 Cheaters (Hacks) mohammad.h915, mh915 On problem A:48264141 48264121 and many othersI hope you look into it PikMike.
•  » » 8 days ago, # ^ |   0 lol
•  » » 8 days ago, # ^ |   0 If they weren't skipped then I would be surprised
 » 8 days ago, # |   0 How to solve problem D
•  » » 8 days ago, # ^ | ← Rev. 3 →   0 for all prime numbers less or equal to n find the graph g that all vertices of it are dividable by n (it may not be connected) and find the longest path on it and then the maximum of these values is the answer. this is of course O(n*logn).
•  » » » 8 days ago, # ^ |   0 How is complexity O(nlogn)?
•  » » » » 8 days ago, # ^ | ← Rev. 6 →   0 because there is at most logn prime factor in n .
•  » » » » » 8 days ago, # ^ |   0 There is not logn prime between 1 to n. It is more.
•  » » » » » » 8 days ago, # ^ | ← Rev. 5 →   0 ّI meant there is at most log n prime factor in n you see each vertex at most logn time so it should be o(nlogn)
•  » » » » » » 8 days ago, # ^ |   +14 In fact, there's less than logN primes for a number <= N (we aren't talking about primes <= N but primes that divide a certain number <= N). It's the inverse of primorial function https://en.wikipedia.org/wiki/Primorial
•  » » » 8 days ago, # ^ |   0 I can't figure out why just pick up prime numbers, can you explain me please?
•  » » » » 8 days ago, # ^ | ← Rev. 4 →   +1 suppose we have the answer it should be a path with gcd more than 1 so all the vertices in the path are dividable by a number(the gcd)though that number is also dividable by some prime numbers. thus all of the vertices are dividable by some prime numbers so picking all prime numbers we can obtain the longest path.
•  » » » » » 7 days ago, # ^ |   0 Thanks bro, I figured out that I need lots of practice at number theory.
•  » » 8 days ago, # ^ | ← Rev. 7 →   +19 You can solve it using modified dfs.How?Let us iterate i from 2 to sqrt(200000), For each i, lets perform dfs:  We try to reach as much depth as possible which is divisible by i, from the current root (let's say j);  Let the top 2 maximum depths reached (using 'j' as root) be f and s;  Thus the longest path can possibly be f+s+1 ( starting from one depth, turning at the root and ending in the other depth).  So we take the maximum out of all of the above mentioned paths for all roots, for all i. Also we need to once run the same dfs given above for each i = a[j]; (where a is given value array and 'j' is the current root).This will cover the case in which every number is a prime.Thus, the final maximum of length of all the paths will give us the answer.Complexity: O(n*sqrt(n))Check my submission for more clarity.UPD: Thaid Thanks for the hack. Was able to find out the error in my method :). Its updated now .
•  » » » 8 days ago, # ^ |   0 Minyoo, reza thanks so much.
•  » » » 8 days ago, # ^ |   +15 Consider this test: 3 1 7207 7207 1 2 1 3 I'm sorry for a hack
•  » » » 8 days ago, # ^ | ← Rev. 6 →   0 It can be done in O(N log N + complexity of prime factorizations) if we consider all prime factors among prime factorizations of values of all vertices. We will create a mapping prime factor -> list of vertices that contain this factor in the prime factorization of their value. Now we iterate over the map and for each prime factor we enable these vertices. Next we iterate over these vertices one more time and if the vertex has not been marked as seen for the current prime before we find the diameter in the tree of currently enabled vertices, rooted at this vertex. The answer is the maximum diameter of a tree we have found in the end. As each vertex only has a maximum of log N prime factors in its factorization, each node is only visited a maximum of log N times.
•  » » » » 7 days ago, # ^ |   0 Your method is correct but instead of map if you simply store vertices in an array of vector, you will get rid of "heavy constant of map".
•  » » » » » 7 days ago, # ^ | ← Rev. 4 →   0 Yes you are right, array of size 200000 should be used instead of STL map, otherwise the complexity will be O(N log^2 N) to build the map: https://codeforces.com/contest/1101/submission/48282989. Prime factorization still requires O(N log^2 N) complexity, thus the overall complexity is O(N log^2 N).
 » 8 days ago, # |   +20 Codeforces should reduce the time for hacking phase.
 » 8 days ago, # |   -33 I noticed that some of my replies(others too) are getting vanished. I can't find them anymore in the comment threads. (I'm not talking about the fading of comments with many downvotes) Moreover, sometimes, when someone replies in my comments, notifications appear in the top. But when I click on the notifications it doesn't redirect me to the reply! What can be the reason?
 » 8 days ago, # |   0 MarcosK is on fire!!! Hacking people like anything!
•  » » 8 days ago, # ^ |   +19 Curious fact: I made 219 hacks with just 2 testcases :P
•  » » » 8 days ago, # ^ |   0 "[]" is one of them right?
•  » » » 7 days ago, # ^ |   0 whats the case?
•  » » » » 7 days ago, # ^ |   0 :[]: and [::]
 » 8 days ago, # |   -47 The comment is hidden because of too negative feedback, click here to view it
•  » » 8 days ago, # ^ |   0 you really are a stupid piece of shit!
 » 8 days ago, # |   +8 Anyone else solved G greedily and has absolutely no clue why it works?
 » 8 days ago, # |   0 Why there are a lot of hacking in problem A and B?
•  » » 8 days ago, # ^ |   +3 For, B: Weak pretests, I think.I did a very silly (wrong) assumption that the characters [, ], : and | are always present in the given string. (I didn't notice this part (1≤|s| ). And unfortunately, all the pretests had all these [, ], : and | characters. There was not a single pretest with |s| < 4.
•  » » » 8 days ago, # ^ |   0 Thank you.
•  » » 7 days ago, # ^ | ← Rev. 2 →   +3 For A: some people submitted a brute force O(n) complexity algorithm and got TLE. Instead O(1) solution was possible
•  » » » 7 days ago, # ^ |   0 OK. Thank you.
 » 8 days ago, # |   +1 Is it possible to solve problem D by rooting the tree at 1?I am actually clueless. I am wondering if it is possible or not?
•  » » 8 days ago, # ^ |   0 it is ... I mean I did that and it got accepted and another clue : think about the prime numbers :)
•  » » 7 days ago, # ^ |   +9 Usually, for trees problems, if not having any specific requirements, rooting from any vertices will always result in one desired value if your ideas/implementation is correct ;)
•  » » » 7 days ago, # ^ |   0 Can you describe something more for "any specific requirements".
•  » » » » 7 days ago, # ^ | ← Rev. 2 →   0 That one is just a criterion given in statements.Like, if the tree is stated to be rooted at 1, and has clear descriptions of its nodes' ascendant-descendant relationship, you have to choose 1 as the root regardless. Otherwise, choosing any vertices as the root doesn't matter.
•  » » » » » 7 days ago, # ^ |   0 I meant by asking that under which condition I cannot root my tree to any specific node if not specified in the question.
•  » » » » » » 7 days ago, # ^ |   0 AFAIK, if the problem statements do not give any details about the specified node to be rooted, you can freely choose your root to start traversing.At least that applies to all DFS/BFS-based traverse.
 » 7 days ago, # |   +36 SomeOne, please update Ratings.
•  » » 7 days ago, # ^ |   +55 Someone is sleeping
 » 7 days ago, # |   +8 So when can the editorial be released?(And also rating changes?)
 » 7 days ago, # |   +11 Why can't rating changes be updated automatically?
 » 7 days ago, # |   0 Why my same solution of B is being accepted now, when it was hacked earlier??
•  » » 7 days ago, # ^ |   0 Please someone clarify this
•  » » » 7 days ago, # ^ |   0 The test case is still old. System test has not yet begun.
•  » » » » 7 days ago, # ^ |   0 Thanks
•  » » » 7 days ago, # ^ |   0 System testing yet to start and your code is passing on the same pretests as it passed earlier, during system test they will merge all the test cases and then check your solution. Good Luck !! Wish you High Rating!
•  » » » » 7 days ago, # ^ |   0 Thanks
 » 7 days ago, # |   +7 Will there be another system test later or it's already finished?
•  » » 7 days ago, # ^ |   0 There will be !! Everyone is eager for it to begin! Wish U a high rating!
•  » » » 7 days ago, # ^ |   +1 Thanks a lot! Wish you a high rating, too!
•  » » 7 days ago, # ^ |   0 it says final standings .I think the system testing is already finished .
•  » » » 7 days ago, # ^ |   0 Not yet, It does say Final standing but system test yet to start. Most of the People waiting for it to start. Good Luck and High rating!!
•  » » » » 7 days ago, # ^ |   0 it always says Final Standings when the system testing is finished
•  » » » » » 7 days ago, # ^ |   0 I still disagree and wait for few hours then they might start.
 » 7 days ago, # |   0 how to slove problem C?
•  » » 7 days ago, # ^ |   0 sort the segments by L iterate over the segments and store the max R . when you find a segment which has L bigger than the current maximum R put it in the other group with all the remaining segments.
 » 7 days ago, # |   +1 Where is the rating?
 » 7 days ago, # |   0 Got Problem F Accepted with a small randomization trick + Binary Search.First of all, I assumed the direct Binary Search would not pass the worst case.What if we can binary search on each truck and find it's minimum required volume and use that result as low of next truck? Also, I did a check before running the binary search if the previous result can already satisfy the current truck.A little improvement but now the question arises, would it still pass on some specific type of ordering of the dataset? Surely not and it didn't.So, I reordered the input order of trucks randomly and ran the same solution which got accepted with pretty fast runtime.TLE Solution without random orderingAccepted Solution with random ordering
•  » » 7 days ago, # ^ |   +7 That's this trick https://codeforces.com/blog/entry/62602 . The complexity is O(N * M + N * logM * logANSWER)
•  » » » 7 days ago, # ^ |   0 Thanks for that. It's explained nicely there :D
 » 7 days ago, # |   -9 Not using fastio in E causes TLE. I think it should be mentioned in the problem statement to use fastio.
•  » » 7 days ago, # ^ |   +43 No, it shouldn't.
•  » » » 7 days ago, # ^ |   +6 What should have already happened is system testing. How long more we'll be waiting?
•  » » » 7 days ago, # ^ | ← Rev. 3 →   0 I thought that the TLE verdict is used to imply that your solution does not adhere to the intended time complexity. It doesn't make any sense if the solution adheres to the intended time complexity but still gets TLE because of just fast IO. After all these are algorithmic contests.Anyways a learning to always use fast IO on CF! :)
•  » » » » 7 days ago, # ^ | ← Rev. 2 →   +77 I would be very excited to see competitive programming problems and contests that test only the correctness and complexity of your solution. But, unfortunately, in reality things are just not like that. There are lots of problems where constant optimizations — fast i/o, bit hacks, replacing % with some subtractions/additions in modular arithmetics — really matter. If we don't cover this in our rounds, then participants would not be prepared to use these optimizations on some real contests.The reason why we don't mention the requirements on fast i/o in the statements is the same: they are rarely mentioned on official competitions, so participants should be able to determine whether they need to use constant optimizations or not by themselves.
•  » » » » » 7 days ago, # ^ | ← Rev. 2 →   +5 doesnt that defeat the purpose of educationals vs regular roundsi mean these are for 'The goal is rather to practice and to educate, than to compete'(as said by MikeMirzayanov), also these are oriented towards second division and newer coders,so i think mentioning it in the question would me more motivating for the newer folk rather than them finding out that they had been doing the correct thing from the beginning but just got TLE bcoz of some damned fastiobtw thanks for replying rationally rather than just some arrogant, "No, it shouldn't."
•  » » » » » » 7 days ago, # ^ | ← Rev. 2 →   0 The education contest was originally designed to make the coder more adapt the regular contest. so through this contest, I think you will definitely pay attention to it later.
•  » » » 7 days ago, # ^ | ← Rev. 2 →   -24 thats not fair,it should be mentioned so that newer programmers get a fair chance of solving. aim of the question is to test the logic(and implementation).i am open to** valid** criticism/discussion about my opinion but at least you should discuss about it not ignore this PikMike
•  » » » 7 days ago, # ^ |   0 Well, may I ask why ? In a comment above, you've mentioned "It is totally fine to remind you to use faster i/o operations once in a while". Surely mentioning it in the problem statement is another way to remind ?
•  » » » » 7 days ago, # ^ |   -11 well if using fastio can change the verdict of the exact same code then i think it is necessary to mention thatbecause fastio is not a differentiating factor when comparing a person who has the right algo, right code, right implementation... with someone with neither of these
•  » » » » » 7 days ago, # ^ |   +16 "...fastio is not a differentiating factor...".I disagree with such proposition. Usually, fastIO is a mistake of newcomers. That's why, it shows your experience in the same way as knowing standart library, math, data structures and other.I can replace "fastIO" with "random bug" in your statement and it will sound the same. And that's because solving the problem is not just having idea, but a complex task, and if you fail at least in one part, you will look the same as "someone with neither of these".And final thought, if you've got TLE because of slowIO, it means that your implementation is not right. And you can only blame yourself.
•  » » » » » » 7 days ago, # ^ |   +2 imagine this case you are new to programming, you give this question a try, you get the logic and are able to write the code correctly now you submit it and get TLE, you are confused and think that maybe there is some problem with logic and u think and think but couldnt find aany, you get very frustrated and after the contest you realise that a simple fastio line could have gotten you AC you were right all along from the beginninghow would you feel, would you be excited that you learned about fastio or angry about some fastio ruining your verdict, would this incident be motivating for you to pursue coding furtherwhat i suggest something like "fastio recommended" in the question of "educational round" and this new programmer learns about it and as well implements it in the first time and gets his code accepted, wont this be more motivating for him
•  » » » » » » » 7 days ago, # ^ |   +26 Frustrating is common feeling, everyone in this community felt it many times, and, if newcomer can't deal with it, then it's his personal problem (moreover, frustrating is caused by his own mistakes). What he has to do is to get valuable information from it and preform better in the future.Ah, and adding "fastio recommended" is bad idea, since almost nobody will learn the lesson. Instead, more people will complain in the future, when they will have to use their own heads.
•  » » » » 7 days ago, # ^ |   +38 Meh, learning doesn't work that way. I believe, learning from your mistakes is the most efficient method of learning.
•  » » » » » 7 days ago, # ^ |   0 ya, agreed but this is like purposely digging a ditch for someone to fall so that they be careful the next time
•  » » » » » » 7 days ago, # ^ | ← Rev. 3 →   +20 Do you think that 500000 queries were just to mess with slow i/o lovers? It was done to guarantee that none of heavily optimized q2 solutions will pass. You can scroll past the previous rounds to see that people were getting n2 AC for n = 105 and some crazy things like that. These low-level compiler optimizations are still black magic to me, so I better ensure it is impossible.
•  » » » » » » » 7 days ago, # ^ |   -8 exactly, you also agree that time limit was to avoid 'heavily optimized q2 solution' getting passed so i was suggesting that you could have added something like "fastio recommended" to this "educational round" and voila problem solved
•  » » » » » » 7 days ago, # ^ | ← Rev. 2 →   0 The input has a clear 3 constant, you should be able to recognize this if you're using a slow read method such as cin/cout. Otherwise just go for the printf/scanf. The large input is a consequence of the required constraints of the problem
•  » » » » » » » 7 days ago, # ^ |   0 imagine this case you are new to programming, you give this question a try, you get the logic and are able to write the code correctly now you submit it and get tle, you are confused and think that maybe there is some problem with logic and u think and think but couldnt find aany, you get very frustated and after the contest you realise that a simple fastio line could have gotten you AC you were right all along from the beginninghow would you feel, would you be excited that you learned about fastio or angry about some fastio ruining your verdict, would this incident be motivating for you to pursue coding furtherwhat i suggest something like "fastio recommended" in the question of "educational round" and this new programmer learns about it and as well implements it in the first time and gets his code accepted, wont this be more motivating for him
•  » » » » » » » » 7 days ago, # ^ |   +8 Seems like a good oportunity to get educated enough about fast io to the point where it's unlikely you'll ever forget againThe suggestion is okay, it's even present from time to time, but it's way different to say suggestion and, textually, "digging a ditch for someone to fall". No, it isn't wrong or required, you're just triggered.
•  » » » » » » » » » 7 days ago, # ^ | ← Rev. 2 →   0 "...digging a ditch..." comment was because of this comment https://codeforces.com/blog/entry/64438?#comment-483948 , it was rude and i felt that i atleast deserved a proper reply at that timei was discussinging and presenting my opinion but this comment was a let down from the problem setter
•  » » » » » 7 days ago, # ^ |   0 ya, agreed but this is like purposely diging a ditch for someone to fall so that they be careful the next time
•  » » » 7 days ago, # ^ | ← Rev. 2 →   0 Maybe is shouldn't but it does. Check it out https://codeforces.com/contest/1101/submission/48266295 https://codeforces.com/contest/1101/submission/48234518 2978 ms and 327. Of course second solution got hacked.
 » 7 days ago, # |   +5 when will the rating changes come out?
»
7 days ago, # |
0

# include <math.h>

using namespace std; typedef long long ll; int main() { int n,i; cin>>n; int maxx=0,maxy=0; for(i=0;i<n;i++) { char c; cin>>c; //cout<<c<<endl; if(c=='+') { int x,y; cin>>x>>y; if(max(x,y)> max(maxx,maxy)) maxx=max(x,y); if(min(x,y)> min(maxx,maxy)) maxy=min(x,y); } if(c=='?') { int h,w; cin>>h>>w; if((h>=maxx&&w>=maxy)||(h>=maxy&&w>=maxx)) cout<<"YES"<<endl; else cout<<"NO"<<endl; } } return 0; }

This is the code of question E, but TLE at test case 7, can anyone explain why TLE is coming?

•  » » 7 days ago, # ^ | ← Rev. 3 →   +6 just add this line before taking input in main()std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
 » 7 days ago, # |   +36 So I've a miraculous solution for G, which I've no idea how it passed. First, I've misread segments into sets, so I thought the elements order does not matter. Second, I couldn't come up with a solution for that version too, but hey, the contest end is so close, so what do we try to do in these cases? Just try out anything without caring a bit about correctness, i.e. think of some greedy/randomized algorithm. I coded a randomized solution, and to my surprise, it passed!After the contest while discussing the idea with a friend who maybe thought I'm sort of alien to think of a solution like this, I only thought he was surprised due to the randomized solution, but then I was shocked when he asked me, how even the answer for dividing into contiguous segments is the same as the answer for dividing into sets?I'm still shocked since then, can anyone help me why is this submission AC?! At least is really the answer for dividing into subarrays the same as dividing into segments? Are they not necessarily but most probably the same? And even so, why is randomized solution getting the correct answer with high probability? To be even more shocking, in the randomized solution I just assumed that the difference between the sizes of the largest and smallest piles is at most 1 xDAnyway, here's a conclusion: never give up on any problem till the last 20 minutes, for that random stupidness can turn out to be equivalent to ultimate intelligence.
•  » » 7 days ago, # ^ |   0 never give up on any problem till the last 10 minutes))) original (I think) solution of problem G is just coding gauss algorithm in 2-6 minutes so keep thinking and generating ideas such as another interpretation of problem at any time of the contest
 » 7 days ago, # | ← Rev. 2 →   +11 500 tests for problem B
•  » » 7 days ago, # ^ |   +3 Its more than 500. At least 562... :O
•  » » » 7 days ago, # ^ |   +3 576 :o
•  » » » » 7 days ago, # ^ |   +12 588
•  » » » 7 days ago, # ^ |   0 1 ;oo
•  » » 7 days ago, # ^ |   +2 Greater than or equal to 588!! Almost 600
 » 7 days ago, # |   +1 Can anyone tell me when will the rating be add to my profile? The contest and open hacking have ended, yet the rating has not been added in my profile.
•  » » 7 days ago, # ^ |   0 This is because final rating is calculated after system testing... and after that it is added to your profile. So wait for system testing to end. After that it won't take much time
 » 7 days ago, # | ← Rev. 2 →   0 I think
 » 7 days ago, # |   +21 When tester got no chill! :p
 » 7 days ago, # |   +16 Longest system testing I've ever seen. 600 tests in B lol.
 » 7 days ago, # |   +1 Why can't I see all of my submitted codes on My Submission tab
•  » » 7 days ago, # ^ |   +1 the UI seems to fall apart during the systests phase... d'ooooooh, SUCH SUSPENSE VERY TENSE
 » 7 days ago, # |   +1 Question B has highest number of hacks I have seen till date. Thus it also has 600 test cases XD
 » 7 days ago, # |   0 I got TLE on C because i didn't use Fast IO :(( These tests are not ok!
•  » » 7 days ago, # ^ |   +1 Same bro. I feel your pain! The bigger problem is when you don't know what to do after that TLE :<
 » 7 days ago, # |   0 What is hack for B? I can't understand why some greedy solutions get WA. All solutions a kind of let's find the first "[" and the first ": ". Afterwards let's find the last "]" and the last ": " before the last "]". And finally let's calculate number of "|" between ": ". The answer is the number of "|" + 4
•  » » 7 days ago, # ^ |   0 I got it accepted with that logic. Maybe the hacks includes cases where you don't have a "[" or "]" at all in your string.
•  » » » 7 days ago, # ^ |   0 Some of them check it.example
•  » » » » 7 days ago, # ^ | ← Rev. 2 →   0 Well implementation mistakes are always a headache when you have your logic correct...
•  » » 7 days ago, # ^ | ← Rev. 4 →   0 :][: Expected Output : -1 A lot of codes output 4.
•  » » » 7 days ago, # ^ |   0 But exactly this code outputs  - 1
•  » » » » 7 days ago, # ^ |   0 Initial value of a=-1 and b=0 and his condition is if a
•  » » » » » 7 days ago, # ^ | ← Rev. 2 →   0 Yes, you're right, I get it.Thank you very much!
•  » » 7 days ago, # ^ | ← Rev. 2 →   0 Got hacked because of a simple mistake of not checking whether the index of 1st colon is greater than 2nd colon, and weak pretests (*insert tears*).
 » 7 days ago, # |   0 So sad, the magic already gone :(. I missed my chance to hack "Legendary Grandmaster" :((
 » 7 days ago, # |   +62 I don't know how bad luck this is.
 » 7 days ago, # |   +1 Post the editorial please.
 » 7 days ago, # |   +1 The round of hacks and test cases!
 » 7 days ago, # |   0 With one pass solution, small (500000) constraint and 3 Sec TL why this -https://codeforces.com/contest/1101/submission/48293304) gets TLE without using Fastio.
•  » » 7 days ago, # ^ |   +3 500000 lines with 1 char and 2 integers each is not small at all, and the output is large too.
 » 7 days ago, # |   0 Why this greedy solution for problem G is correct ?This one
 » 7 days ago, # | ← Rev. 2 →   0 Hey anyone, can you help me with D? I used a DFS call from current node and the trailing recursion and passed them separate visited arrays, can't get the prime number solution some people are suggesting, any elaborations please? :'(Here is my code
 » 7 days ago, # |   0 Can someone help me with my solution for C
 » 7 days ago, # | ← Rev. 2 →   0 Can somebody find mistake in my code in problem D, please?https://codeforces.com/contest/1101/submission/48296920Or can you tell me what is the test 4 in this problem?
 » 7 days ago, # |   0 Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).
 » 7 days ago, # |   0 Auto comment: topic has been updated by PikMike (previous revision, new revision, compare).
 » 7 days ago, # |   +3 Can someone please explain to me why I got TLE in this submission and when I submitted the same code but after replacing the array of long long "ll ans[200005];" with the array of int "int ans[200005];" in this submission I got Accepted ? It happened to me during the contest and I got hacked on my submission with long long because it got TLE!
•  » » 7 days ago, # ^ |   +1 Memset works at byte-level, meaning that your memset() now takes twice the time with long long. You shouldn't do this memset here to begin with (with good constraints it would also TLE with int), you should use the fact that the sum of all N is 1e5 and so just zero only the first N elements of ans[] for each testcase.
•  » » » 7 days ago, # ^ |   +1 It's clearer now, thank you!