awoo's blog

By awoo, history, 6 years ago, translation, In English

Hello Codeforces!

On Jan/11/2019 17:35 (Moscow time) Educational Codeforces Round 58 (Rated for Div. 2) will start.

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 vintage_Vlad_Makeev 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
4 TadijaSebez 7 217
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 ngfam 0:17
E Alif01 0:03
F krijgertje 0:48
G RUSH_D_CAT 0:11

UPD: The editorial is out

  • Vote: I like it
  • +215
  • Vote: I do not like it

| Write comment?
»
6 years ago, # |
  Vote: I like it +197 Vote: I do not like it

Uhh, can't wait til BledDest, Roms and vovuh finally get rid of their new year colors!

»
6 years ago, # |
  Vote: I like it +13 Vote: I do not like it

awoo has been problem settler over 50 contest, it's even more than number of contests I've ever participated. Where those problems come from?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +41 Vote: I do not like it

    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!)

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +17 Vote: I do not like it

      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).

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +25 Vote: I do not like it

      Any way thank you for Educational rounds. ;)

  • »
    »
    6 years ago, # ^ |
      Vote: I like it -28 Vote: I do not like it

    Google)

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Ctrl A Ctrl C Ctrl V Compile Activated

»
6 years ago, # |
  Vote: I like it +30 Vote: I do not like it

Is PikMike MikeMirzayanov, since PikMike didn't thank him?

»
6 years ago, # |
  Vote: I like it -60 Vote: I do not like it

The worst educational round ever!

»
6 years ago, # |
  Vote: I like it -15 Vote: I do not like it

Weak pretests, my solutions passed >:(

»
6 years ago, # |
Rev. 2   Vote: I like it +11 Vote: I do not like it

it's weird if E is that easy :P maybe that's new year gift from santa PikMike or something

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Jhin just comment out the fast input and submit again

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Wow man, I got a TLE on 7 when I removed FIO :O

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    I though the same but after seeing the number of submissions,figured it was probably easy.

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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?

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

So how do you solve F if binary search + greedy is too slow?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +18 Vote: I do not like it
    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +14 Vote: I do not like it

      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.

    • »
      »
      »
      6 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      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

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Wow, that seems like such a simple trick in hindsight. I'll try not to forget it. Thanks!

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve problem G? I could only figure out that the answer must be less than 30.

  • »
    »
    6 years ago, # ^ |
    Rev. 6   Vote: I like it +19 Vote: I do not like it

    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 fi

    2, 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.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      check if f[n] is an element of some basis is just checking that f[n] != 0, right?

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Yes

      • »
        »
        »
        »
        6 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        Yeah.

        I'm interested in the proof that checking all prefixes is sufficient, though. I couldn't prove it. :/

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it +9 Vote: I do not like it

          Let's say you have 3 values

          b[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.

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Thanks!

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
            Rev. 2   Vote: I like it 0 Vote: I do not like it

            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?!

            • »
              »
              »
              »
              »
              »
              »
              6 years ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              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.

              • »
                »
                »
                »
                »
                »
                »
                »
                6 years ago, # ^ |
                Rev. 2   Vote: I like it 0 Vote: I do not like it

                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..?

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  6 years ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  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.

                • »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  »
                  6 years ago, # ^ |
                    Vote: I like it 0 Vote: I do not like it

                  Got it.. Thanks..!!

»
6 years ago, # |
  Vote: I like it -9 Vote: I do not like it

Is it just me? I got TLE in Problem E, this is my solution. https://codeforces.me/contest/1101/submission/48246073

After scratching my head for some minutes, I added

ios_base::sync_with_stdio(false);
cin.tie(NULL);

And voila, it passed.

»
6 years ago, # |
  Vote: I like it +10 Vote: I do not like it

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 rating

F for prayers

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    F

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +12 Vote: I do not like it

      I literally thought i had to print the number of characters i eliminated.

      Kill me

      • »
        »
        »
        »
        6 years ago, # ^ |
        Rev. 2   Vote: I like it +1 Vote: I do not like it

        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

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Does greedy with binary search work for F? I got a TLE on 23rd test.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Binary-search can't pass timelimit!

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    shuffle the array randomly first

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can you elaborate on which array to shuffle? We need to maintain contiguity in cities right?

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it +15 Vote: I do not like it

        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 search

        shuffling just increase the chance of getting the highest fuel quickly.

»
6 years ago, # |
  Vote: I like it -14 Vote: I do not like it

awoo https://codeforces.me/contest/1101/submission/48242640 https://codeforces.me/contest/1101/submission/48241968 the only difference is fast input line i dont think thats how you decide the outcome of a question

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

what can be the test case 4 of problem C ?

»
6 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

Well, idk if I was tired or whatever, but B seemed really hard to me, maybe one of the hardest B's ever imo.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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 ':'.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I have AC, it just happened that I found it extremely hard.

»
6 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

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. :(

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve C?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it +1 Vote: I do not like it

    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.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
6 years ago, # |
  Vote: I like it +20 Vote: I do not like it

That moment when E has more AC than C

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I think you misunderstood the problem.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      can you give me any test cases?? The test case for which my code went wrong is not being shown.

      • »
        »
        »
        »
        6 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        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.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thought about the intersection part and understood my mistake!!!

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        That's great. But also, you should not expect an O(n^2) solution to pass anyways.

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          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..

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            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.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

A better version of problem E would be to find the number of bills inside the wallet for each query.

Solution: Click here

Time Complexiy: O(Nlog^2N)

Space Complexity: O(NlogN).

Any better solution?

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

How to solve D?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    For each prime p find vertices that p | a[i], and find max path in every component of graph consisting of vertices you found.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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?

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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.

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it +1 Vote: I do not like it

          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

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Will it fit in time limit?

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        There can be only 7 unique primes that divide every number, so it's O(N).

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why are there so many problems for which the query is given?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

Problem D Code Can someone please tell what's wrong in this code?

»
6 years ago, # |
Rev. 2   Vote: I like it -7 Vote: I do not like it

Good contest!

»
6 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

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.

»
6 years ago, # |
  Vote: I like it +4 Vote: I do not like it

What are the prerequisites to solve G? And please can anyone suggest relevant resources for the same?

»
6 years ago, # |
  Vote: I like it +67 Vote: I do not like it

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.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    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.

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

thanks for good contest .I was surprised to see problem e is easier than b and c.

»
6 years ago, # |
  Vote: I like it +28 Vote: I do not like it

Cheaters Odin- , timo14z On all Problems : D

A: 48219687 , 48218791

B: 48223299 , 48224656

C: 48234891 , 48232754

D: 48239659 , 48241851

E: 48227416 , 48230879

I hope you look into it awoo.

  • »
    »
    6 years ago, # ^ |
    Rev. 4   Vote: I like it -6 Vote: I do not like it

    they will probably be skipped wether you say it or not.

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it +21 Vote: I do not like it

    it's a shame that a former contest writer is doing this

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

How to optimize this solution for F. I used randomization but I have TLE on test 23

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

after doing E got the importance of
ios_base::sync_with_stdio(false);

cin.tie(NULL);

»
6 years ago, # |
  Vote: I like it +6 Vote: I do not like it

What's going on with the hacks on E? Is the hack making the solution TLE because of the slow input?

»
6 years ago, # |
  Vote: I like it +14 Vote: I do not like it

How to solve G

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

please help!!! why my code is showing TLE https://codeforces.me/contest/1101/submission/48260807

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    add these lines:

    ios_base::sync_with_stdio(0); cin.tie(NULL);

»
6 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Do hacks give points??

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Not in educational or Div3. But gaining top position in Hackers Table is prestigious.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      Besides, if you make more hacks, you can get a higher ranking since others drop.

»
6 years ago, # |
  Vote: I like it +4 Vote: I do not like it

I solved E faster than B.. :/

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve C?

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it +1 Vote: I do not like it

    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.

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    As there are many test case, try to clean vectors only if they are less than or equal n, not maxn.

»
6 years ago, # |
Rev. 2   Vote: I like it +45 Vote: I do not like it

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.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    isnt the hack file too large to be submitted as testcase?

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      One can generate the input by writing a generator code.

»
6 years ago, # |
Rev. 2   Vote: I like it +9 Vote: I do not like it

Little overkill I made on problem D .. :) I used Centroid Decomposition!!

https://codeforces.me/contest/1101/submission/48257605

»
6 years ago, # |
Rev. 2   Vote: I like it +24 Vote: I do not like it

Im GENIUS!!! Im hacked all people, who solved problem B on PascalABC... INCLUDE ME..IM SUPER GENIUS...!!

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

haha so glad i skipped this one see the people getting hacked off:))))))))))))))=)))))))))

»
6 years ago, # |
Rev. 2   Vote: I like it +4 Vote: I do not like it

Cheaters (Hacks) Mohammad.H915, NeverSee On problem A:

48264141 48264121 and many others

I hope you look into it awoo.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve problem D

  • »
    »
    6 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    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).

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      How is complexity O(nlogn)?

      • »
        »
        »
        »
        6 years ago, # ^ |
        Rev. 6   Vote: I like it 0 Vote: I do not like it

        because there is at most logn prime factor in n .

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          There is not logn prime between 1 to n. It is more.

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
            Rev. 5   Vote: I like it 0 Vote: I do not like it

            ّ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)

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
              Vote: I like it +14 Vote: I do not like it

            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

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I can't figure out why just pick up prime numbers, can you explain me please?

      • »
        »
        »
        »
        6 years ago, # ^ |
        Rev. 4   Vote: I like it +1 Vote: I do not like it

        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.

  • »
    »
    6 years ago, # ^ |
    Rev. 7   Vote: I like it +19 Vote: I do not like it

    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 .

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +15 Vote: I do not like it

      Consider this test:

      3
      1 7207 7207
      1 2
      1 3
      

      I'm sorry for a hack

    • »
      »
      »
      6 years ago, # ^ |
      Rev. 6   Vote: I like it 0 Vote: I do not like it

      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.

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        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".

»
6 years ago, # |
  Vote: I like it +20 Vote: I do not like it

Codeforces should reduce the time for hacking phase.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

MarcosK is on fire!!! Hacking people like anything!

»
6 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Anyone else solved G greedily and has absolutely no clue why it works?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why there are a lot of hacking in problem A and B?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    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.

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it +3 Vote: I do not like it

    For A: some people submitted a brute force O(n) complexity algorithm and got TLE. Instead O(1) solution was possible

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

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?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    it is ... I mean I did that and it got accepted and another clue : think about the prime numbers :)

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    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 ;)

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Can you describe something more for "any specific requirements".

      • »
        »
        »
        »
        6 years ago, # ^ |
        Rev. 2   Vote: I like it 0 Vote: I do not like it

        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.

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          I meant by asking that under which condition I cannot root my tree to any specific node if not specified in the question.

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            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.

»
6 years ago, # |
  Vote: I like it +36 Vote: I do not like it

SomeOne, please update Ratings.

»
6 years ago, # |
  Vote: I like it +8 Vote: I do not like it

So when can the editorial be released?(And also rating changes?)

»
6 years ago, # |
  Vote: I like it +11 Vote: I do not like it

Why can't rating changes be updated automatically?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why my same solution of B is being accepted now, when it was hacked earlier??

»
6 years ago, # |
  Vote: I like it +7 Vote: I do not like it

Will there be another system test later or it's already finished?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    There will be !! Everyone is eager for it to begin! Wish U a high rating!

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +1 Vote: I do not like it

      Thanks a lot! Wish you a high rating, too!

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    it says final standings .

    I think the system testing is already finished .

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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!!

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        it always says Final Standings when the system testing is finished

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

how to slove problem C?

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Where is the rating?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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 ordering

Accepted Solution with random ordering

»
6 years ago, # |
  Vote: I like it -9 Vote: I do not like it

Not using fastio in E causes TLE. I think it should be mentioned in the problem statement to use fastio.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +43 Vote: I do not like it

    No, it shouldn't.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it +6 Vote: I do not like it

      What should have already happened is system testing. How long more we'll be waiting?

    • »
      »
      »
      6 years ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      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! :)

      • »
        »
        »
        »
        6 years ago, # ^ |
        Rev. 2   Vote: I like it +77 Vote: I do not like it

        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.

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
          Rev. 2   Vote: I like it +5 Vote: I do not like it

          doesnt that defeat the purpose of educationals vs regular rounds

          i 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 fastio

          btw thanks for replying rationally rather than just some arrogant, "No, it shouldn't."

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
            Rev. 2   Vote: I like it 0 Vote: I do not like it

            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.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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 ?

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it -11 Vote: I do not like it

        well if using fastio can change the verdict of the exact same code then i think it is necessary to mention that

        because 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

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it +16 Vote: I do not like it

          "...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.

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
              Vote: I like it +2 Vote: I do not like it

            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 beginning

            how 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 further

            what 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

            • »
              »
              »
              »
              »
              »
              »
              6 years ago, # ^ |
                Vote: I like it +26 Vote: I do not like it

              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.

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it +38 Vote: I do not like it

        Meh, learning doesn't work that way. I believe, learning from your mistakes is the most efficient method of learning.

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          ya, agreed but this is like purposely digging a ditch for someone to fall so that they be careful the next time

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
            Rev. 3   Vote: I like it +20 Vote: I do not like it

            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.

          • »
            »
            »
            »
            »
            »
            6 years ago, # ^ |
            Rev. 2   Vote: I like it 0 Vote: I do not like it

            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

            • »
              »
              »
              »
              »
              »
              »
              6 years ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              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 beginning

              how 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 further

              what 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

              • »
                »
                »
                »
                »
                »
                »
                »
                6 years ago, # ^ |
                  Vote: I like it +8 Vote: I do not like it

                Seems like a good oportunity to get educated enough about fast io to the point where it's unlikely you'll ever forget again

                The 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.

    • »
      »
      »
      6 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Maybe is shouldn't but it does. Check it out https://codeforces.me/contest/1101/submission/48266295 https://codeforces.me/contest/1101/submission/48234518 2978 ms and 327. Of course second solution got hacked.

»
6 years ago, # |
  Vote: I like it +5 Vote: I do not like it

when will the rating changes come out?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

include

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?

  • »
    »
    6 years ago, # ^ |
    Rev. 3   Vote: I like it +6 Vote: I do not like it

    just add this line before taking input in main()

    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

»
6 years ago, # |
  Vote: I like it +36 Vote: I do not like it

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 xD

Anyway, 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.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

»
6 years ago, # |
Rev. 2   Vote: I like it +11 Vote: I do not like it

500 tests for problem B

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

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.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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

»
6 years ago, # |
  Vote: I like it +21 Vote: I do not like it

When tester got no chill! :p

»
6 years ago, # |
  Vote: I like it +16 Vote: I do not like it

Longest system testing I've ever seen. 600 tests in B lol.

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Why can't I see all of my submitted codes on My Submission tab

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    the UI seems to fall apart during the systests phase... d'ooooooh, SUCH SUSPENSE VERY TENSE

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Question B has highest number of hacks I have seen till date. Thus it also has 600 test cases XD

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I got TLE on C because i didn't use Fast IO :(( These tests are not ok!

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Same bro. I feel your pain! The bigger problem is when you don't know what to do after that TLE :<

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    6 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I got it accepted with that logic. Maybe the hacks includes cases where you don't have a "[" or "]" at all in your string.

  • »
    »
    6 years ago, # ^ |
    Rev. 4   Vote: I like it 0 Vote: I do not like it

    :][:
    Expected Output : -1
    A lot of codes output 4.

    • »
      »
      »
      6 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      But exactly this code outputs  - 1

      • »
        »
        »
        »
        6 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Initial value of a=-1 and b=0 and his condition is if a<b but that's true when we don't have [ for example ::] that would output 4

        • »
          »
          »
          »
          »
          6 years ago, # ^ |
          Rev. 2   Vote: I like it 0 Vote: I do not like it

          Yes, you're right, I get it.

          Thank you very much!

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

So sad, the magic already gone :(. I missed my chance to hack "Legendary Grandmaster" :((

»
6 years ago, # |
  Vote: I like it +62 Vote: I do not like it

I don't know how bad luck this is.

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Post the editorial please.

»
6 years ago, # |
  Vote: I like it +1 Vote: I do not like it

The round of hacks and test cases!

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

With one pass solution, small (500000) constraint and 3 Sec TL why this -https://codeforces.me/contest/1101/submission/48293304) gets TLE without using Fastio.

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    500000 lines with 1 char and 2 integers each is not small at all, and the output is large too.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why this greedy solution for problem G is correct ?This one

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

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

»
6 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Can somebody find mistake in my code in problem D, please?

https://codeforces.me/contest/1101/submission/48296920

Or can you tell me what is the test 4 in this problem?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by awoo (previous revision, new revision, compare).

»
6 years ago, # |
  Vote: I like it +3 Vote: I do not like it

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!

  • »
    »
    6 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    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.

»
6 years ago, # |
  Vote: I like it +6 Vote: I do not like it

And I thought I was going to be one of the top hackers with 12 hacks. :P

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

About problem E, is a truly fact that in complexity a solution with or without fast i/o has the same complexity, but this is a programming competition where if you take a look is about problems that has a different behaviour in their running time, is not the same the complexity and the running time, is not the same theory and practice. Programming contest is the practice side.

»
6 years ago, # |
  Vote: I like it +7 Vote: I do not like it

_bacali(the best hacker) told me that he write a script to hack.I think its a useful way to find some codes are not right while they passed pretests.I think system should use this to add more tests in main test and find the wrong code which passed the pretests. Sorry for my poor English and poor rating.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How the ans for second test case in 2 in Problem D...? Can someone show the path that creates distance 2?
shouldn't the path is 1-3 (2,4) ?
Testcase 2:
3
2 3 4
1 3
2 3

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone tell me why my submission for B. Accordion is TLE even though it runs in O(n)? https://codeforces.me/contest/1101/submission/48231331