rgrg4's blog

By rgrg4, history, 4 years ago, In English

Sometimes we have a good contest while in others we don't perform well. Just to lift your mood can you people share some funny incidents that happened with you during your competitive programming journey

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

| Write comment?
»
4 years ago, # |
Rev. 3   Vote: I like it +34 Vote: I do not like it

Codeforces Round 694 (Div. 1)

I submitted B at 00:25 (103410744), pretests passed, 1998/2000 ms.

At 00:30, I decided to replace all long long with int and I resubmitted, TLE on pretest 3.

I moved to C, I got pretests passed at 01:33.

I checked the standings. It turned out that D was much easier than C, and it was worth 500 more points. I was unable to solve it in the remaining time.

I failed system tests on B (TLE on test 7).

After system tests, I resubmitted B with int, still TLE on test 3.

A moment later, I realized that there's $$$w \leq 10^{18}$$$ in the input ($$$w$$$ was quite a useless variable, since every query with $$$w \geq 1$$$ had the same answer regardless of the value of $$$w$$$).

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

    You should learn about the linear prime sieve

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

      For some reason, I thought that the bottleneck in my code was the map of vectors, not the factorization.

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

    In the same contest, when I solved problem B I saw that most people re solving C so I started solving it. When I finished, I saw D was solved twice as C so I said That I could've gotten much more points solving D and I was sad. An hour later, C failed system testing. Thank god there's no "Deactivate Codeforces account" button.

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

I got a wrong answer in contest only because i forgot to remove cout << "hi" 99846875

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

    Is there a reason people don't use cerr, I don't see it a lot in people's code

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

      You mean for debugging?

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

      Yes. It is flushed whenever you use the << operator, as unitbuf is set. This is basically like endl whenever you do cerr. That's why its sometimes not good for runtime to use cerr.

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

        Yes, it's not good to use cerr in runtime, but that's not the only usecase. Usually I use cerr for debugging and comment it just before submitting the solution. But if I accidentally forget to do that, there's high chance the submission passes TL and doesn't yield WA.

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

I once spent an hour figuring out what was giving me WA. Turns out I had written a-=min(a,b); b-=min(a,b) ignoring that value of a was getting changed in my code. Lesson learnt!! :weep:

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

Once I wrote #pragma GCC optimize("Ofast,untroll-loops").

The trolls are definitely gone.

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

In codeforces round #698 I submitted 5 wrong answers for B. My first submission was at 00:31 and my Accepted solution at 1:14(with a minus of 250 points for Wrong Answers). The example test case had the value of d(which was the input) as 7. So while writing my code instead of using d I used 7 everywhere instead. All my example testcases passed because of this but got WA at testcase 2. It took my half an hour to realize that I needed to replace 7 with d. Here is my incorrect solution — 105742575

»
4 years ago, # |
Rev. 3   Vote: I like it -27 Vote: I do not like it

#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

In a contest i wrote IOS after cin>>t . My code was working fine locally but was giving wrong answer on some pretest. I moved IOS before cin>>t and it worked . Does someone know why it was actually causing the error ?

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

    Lol, cout.tie(NULL).

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

      Even i removed cout.tie(NULL) , I am still getting wrong answer if i use IOS after cin>>t , submission

      Why Lol ?

      Also people who downvoted the comment above , may i know the reason ? If you provide feedback then i will ask my doubts next time with more care .

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

        If this function is called after I/O has occurred on the standard stream, the behavior is implementation-defined: implementations range from no effect to destroying the read buffer.

        Reference

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

          Thanks a lot . Also i am happy that unlike above person you didn't trolled and helped me instead . Thanks :)

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

        cout.tie(NULL) does literally nothing because cout is already tied to NULL.

        In general I think people should read the documentation for such things instead of just pasting them "because it makes input faster". This would also have prevented your confusion here because the documentation tells you that the effect of calling that after reading input is implementation-defined.

        Also people who downvoted the comment above , may i know the reason ? If you provide feedback then i will ask my doubts next time with more care .

        I think you got downvoted because this was supposed to be a thread for sharing funny stories. Your story wasn't very funny, it was more like "asking a queston".

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

          I think you got downvoted because this was supposed to be a thread for sharing funny stories. Your story wasn't very funny.

          I remember it was at 0 votes before you replied.

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

          My question wasn't on asking advice like what i should do before making a template .

          I already knew that cout.tie(NULL) doesn't helps in making things fast (I read that in a blog on codeforces) . I made the template long back and didn't had any reason to change it . So why Lol in it ? I can tell few red coders still using cout.tie(NULL) . It's on me to change something or not .

          I think you got downvoted because this was supposed to be a thread for sharing funny stories. Your story wasn't very funny, it was more like "asking a queston". When a contest announcement blog is made but people also discuss problems there.

          I thought my mistake was funny and i asked people how it was wrong at the same time .

          Did you really Laughed Out Loud after reading my comment ?

          You have contributed to community a lot (through some interesting blogs) . Thanks for that . But i want to tell that i have seen you quite often making lol and similar comments on peoples silly mistake (usually low rated). I find it very bad thing tbh .

          Also as EnterYourName said, i also saw that i had zero votes till you didn't replied . I don't know if you downvoted (since high rated users have more voting power) or lot of people downvoted but it was mostly due to your LOL comment .

          Thanks anyway to both you and EnterYourName for Discussion . I agree with your point that one should read documentations and should not make off topic comments but that could have been told in first comment itself .

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

            Why do you even care about upvotes/downvotes?

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

              Yeah you are right . Contribution on codeforces doesn't actually represent how much person is really contributing .

              My both comments aren't that bad to get that much downvote .

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

              Comment #1 Comment #2

              Yeah. Why should someone even care about upvotes/downvotes? They could either play it off by saying "Oh I'mma get downvoted".

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

                It seems that apparently I was correct.

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

                  Yeah. You're the guy that says "I'm not a racist" and then make some racist joke.

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

                  So many people cheating from a particular country in almost every contest,so who was to blame then? Don't give me that shit:"Most Indians are not not cheaters bla bla bla...". Even many Indians themselves accepted that it was the problem of their country.

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

                  I don't wanna beat around the bush.

                  Everyone does care when they're downvoted.

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

          This should have been your reply in the first place.

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

            This should have been your reply in the first place.

            That's true . And i actually didn't asked about what he answered . Instead this reply was on-topic with my comment. But instead he has got higher votes than that person.

            Thing is i didn't got down-voted by lot of users , but by few high rated users (High rated users votes have more absolute value).

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

              Instead this reply was on-topic with my comment.

              Despite being its helpful, It somehow got downvoted than earlier lol.

              I'm sick of these irrational guys but gotta take it for granted.

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

100954176 I put a break before reading the entire input in a multitest problem. It took me half an hour after the contest to realize the mistake.

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

In round 689, I got WA on a problem because of forgetting to print a newline in one of answers of the edge cases. 100942496

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

This happens quite often with me. I solve a question with answer as "YES" or "NO". It works fine on my system, giving all the answers correctly. But when I upload it, I get wrong answer. I spend a lot of time figuring out what is wrong with my algorithm, change my code in varied ways, only to realize at the end that the problem was with the way I printed yes and no.

»
4 years ago, # |
  Vote: I like it -29 Vote: I do not like it

Seeing poor performance at my end, I left a contest midway to do otherwise unimportant work. When I resumed after returning, I failed to submit E due to the shortage of a few seconds. Sed Lyf

Thankfully this only happened during a virtual contest xP Lesson Learnt!

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

In Codeforces Round 594 (Div. 2), I forgot to use long long in both the div2A (62980149) and the div2B (62990647), went grey because of that D:

Also my solution for Good Bye 2020 E passed in 1996ms for a 2000ms TL, the same code passed in 600ms using C++17 (64)

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

Umm... before educational round 103, I made some changes in my template or better say I changed

#define ll long long int

to

#define ll int

I ended up making 10 wrong submissions for problem B and realised the mistake after checking my template.

P.S. Don't code while you are drunk.

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

I solved only one Question in last educational round and that too someone hacked.

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

I submitted B in place of C and lost points... :P

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

When I was participating in the first contest of my life, I didn't know that the difficulties increase so much, so when I couldn't solve the easier problems, I opened F thinking that maybe it would be easier than the previous problems. But obviously, I didn't even understand the statement.

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

    How many problems you solved before participating in your first cf round?

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

      CF+hackerrank combined, around 200

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

        How so Orz. You solved 3 problems in your 1st contest, and I can't solve 3 problems in any contest even after 1 year of giving almost 100 contests.

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

    why is this funny ? This sounds more like a flex tbh,

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

      No flex . He is really good . He achieved red in 2 years which most people achieve in 4-6 years . Don't be jealous of him . Most of the comments in this blog aren't funny tbh and this blog title and description don't align .

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

      this was fuuny actually that a person can't solve d but was trying E and F

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

        Yeah that was the joke. It sounded like a flex because I mentioned "first contest", but anybody would do such a mistake in first few contests only.

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

          I did something similar in the last one. Couldn't crack E, tussled with F despite seeing 0 accepted submissions on it (too naive in hindsight). Didn't fathom it'd be rated 3000 even after being thrashed in the face by vain attempts, LOL.

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

    so you are saying that even after solving 200 questions and possibly knowing from your peers / seniors that difficulty increases in cf contest, you thought that E and F were easier.... thats hilarious!!

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

      The funniest part in this thread is your username.

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

      I only solved easy problems from a2oj ladders, I didn't know anything about levels, divisions or ratings.

      You can actually check my earliest submissions, at least 150 of them are only from a2oj ladders.

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

      okk I can see your jealousy to him,Its common bro that a guy cant know about difficulty,200 qsn didn't justify that he should know about codeforces....

      Why judging him so much ,,Oh! cause u havn't guts to reach the level at which healthyUG is...

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

        I am not disrespecting anyone, i have seen his videos and he is doing a great job, and i would try to reach his level even if i cant , i was just curious about how he practiced before CF which he clearly stated in the comments

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

    demoralizer massive respect man !!
    Coincidently we are from the same city !!
    mile kabhi VT pe :-p

»
4 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it
  1. if(a>b)?cout<<"Yes":cout<<"No";
  2. int i,j,n,m; for(i=0;i<n;i++) { for(j=0;j<n;j++) { } for(i=0;i<m;i++} { } } Figuring out why program is running for so long time(infinite).
»
4 years ago, # |
  Vote: I like it -20 Vote: I do not like it

Replacing endl with "\n" got me from TLE to AC.

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

I once wrote for (int i = 1 ; i <= n ; n++) and it took me 30 minutes to debug

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

I once wrote #define ing long long in my school's contest and spent 30 minutes trying to figure out why I got Wrong answer on test 3.

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

During a contest, I attempted at solving problem E because it felt easier than a usual E. I didn't realize that I was trying E and submitting on D :( I didn't realize it even after the contest ended and was trying really hard to debug and find what's wrong. 1-gon Monogorz helped me find the bug :clownglasses: :ghosthug:

Untitled

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

I got a tle in one solution because I was using long long int instead of int

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

Rookie here. In my first div 3 contest, I happily solved problems A and B and submitted the code at around 00:15 but got CE. Spent 40 mins trying to find the bug but still failed. Turns out that I selected the wrong language. Dang.

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

I once implemented two segment trees to find minimum and maximum element in the range related problem of the array. It was a sorted array (-_-)

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

1) Once, I had pretests fail just because I forgot to print "new line" on a corner case.

2) Once, I had pretests fail on a 1900 level problem (hardest in-contest problem) just becuase I forgot the case of 1.

3) Once, I had system-tests fail because I forgot to return m on a corner case.

4) Once, I had system-tests fail because of long long issues.

5) In the most recent contest, I spent 3 minutes of A, 30 minutes (ish) trying to solve B, then looked at C & solved it. After solving C, I finally figured out how to solve B, but I ran out of time. It turns out my A solution was hacked because of some dumb errors, so in teh most recent contest, I only solved question C.

6) Once, I accidently submitted problem D to the problem C slot, hence making me lose 50 more delta than before.

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

My solution got hacked because I used ceil(). Though, I learnt a lesson that I won't do this mistake in future.

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

Once I was returning the answer even before taking the whole input....RIP

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

In vector I made assigned values like v[i] = a, instead of v.push_back(a) in D problem. This was the only mistake in my solution during contest.

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

found this once Codeforces Dual

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

Once I got wrong answer on test case 149.I thought that I may be missing some edge case. But eventually it turned out that my whole logic was wrong but still it was able to pass 148 test cases.

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

Once i got wrong answer just because i have printed "N0" instead of "NO" . https://codeforces.net/contest/1388/submission/88469165

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

    Once i tried to solve the very first question on the constraints given on an example .

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

In a contest, I failed a system test just because my code was printing 1e12 instead of 1000000000000 :\ sed lyf...

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

Codeforces Round #470. It's my first contest, I'm getting ready, I've been solving problems for a year now and I'm ready to get these problems solved. The contest started and I have no clue why the problems are that hard. I've read A, B and C and didn't have any idea so I moved to problem D and I thought I can solve this one.

One and half and hour has passed and I finished the code but I couldn't submit because I didn't register to the contest. Oh god, I'm in Div.1! I moved to Div.2 so quickly and solved problem A and started finding problem D in the Div.1, which was problem E in the Div.2, I got a wrong answer (obviously) and A didn't passed system testing. My university's coaches laugh at me until now, although my code had a bug and I solved it after the contest.

Don't code problem D Div.1 when you can't solve A Div.2.

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

In 2018, during the last phase of the Brazilian OI, I forgot to put the '\n' in one of my printfs in a segment tree problem, I tested the cases and everything seemed fine, because it hadn't reach the if that contained the bad printf. The contest was blind, so I ended with 0 points on that problem, thus not reaching the Team Selection Phase for IOI.

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

This took my whole morning : D

for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++i)
        do_something_with(i, j);
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

In the cf edu round 103 for problem B i wrote a correct code within 15 mins but I overwrote it on solution of A and wasted like more than 25 mins to find the bug. I had written the code for A in test_case() function but for B i wrote in precompute() function without erasing solution of A. Lol.

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

    Just a tip if you (or someone else) uses vim, you can use :u0 to restore the file to it's initial state at the time of opening. You can do that and start doing the next problem with a clean slate.

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

once I used the same iterator variable inside a nested nogic, almost went mad debugging!

for (int i = 0; i < n; ++i){
    for (int j = 0; j < m; ++j){
        // somestuff
    }
     //again somestuff
    for(int i = 0; i < k; ++i){  // here I again used i as the for loop iterator
          
    }
}
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I secured 179 rank in CF round #692. Particularly because I did B problem very quickly. But when my friend asked me about the reason I used brute force to solve it, I was dumb and just said strong intuition made me write a brute force.

A few contests later, I secure 6086 rank in CF round #698, where I couldn't solve the B problem. But ironically, the way my friend solved the same problem was strong intuition and brute force only and he was unable to state a proof to it xD. The same condition like a recent problem but roles switched!

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

Submitted in the wrong problem and got "Wrong Answer on Pretest 2".

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

Well this happened to me in some atcoder ABC a while back...I had to print Takahashi in some problem as answer but I was printing Takashi. Costed me some reasonable amount of time :(

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

Once I've wrote two different ok solutions for this 987E - Petr and Permutations problem only to realize I was misspelling Um_nik with Um_Nik. Always read the statements!

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

I did an oopsie in Codeforces round #700 div2/B. Instead of "<=" I used "<" and pretests were passed during the live contest but gave WA after system testing. Sed lyf I guess :(

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

I started Quora Programming Contest Div 2 (actually it is just round 2) late by 50 minutes. I thought it started at 10 am local time when it is actually 9 am.

In the last few minutes I was fine-tuning some weights for an ML task and luckily got into top 50 for the shirt.

I learnt to never give up :P