### Fear_Is_An_Illusion's blog

By Fear_Is_An_Illusion, 6 years ago,

Silly mistakes are like syntax errors. They can cause your entire program to become useless. Pity that there is no compiler for detecting them.

So whats the silliest mistake you have ever done in a contest problem ? And when you realized it later, you had that "WTF was I thinking then" kind of feeling.

Yesterday while doing div 2 B, I was pretty confident that my approach was correct, but kept failing a pretest.

I couldnt sleep properly due to that mistake, so I woke up at 3am and found this stupid silly mistake.

• +30

 » 6 years ago, # |   +31 Not something I personally did, but on a TC today I saw someone whose solution failed during the challenge phase because they modded by 10e9 + 7 instead of 1e9 + 7. Whoops.
•  » » 6 years ago, # ^ |   +2 And now, with this morning's contest, I am myself guilty of a similar crime on this problem. -.-(Why was the mod 109 + 9 on that problem, but 109 + 7 on all of the others?)
•  » » 3 years ago, # ^ |   -23 Three years down the lane, still relevant!
•  » » » 4 months ago, # ^ |   -8 6 years down the lane still revelent
•  » » » » 4 months ago, # ^ |   +7 this except with the Zashikhin prime
 » 6 years ago, # |   0 In a CF round I got RE because I must change 100 to 500! I don't want to think about that :(
 » 6 years ago, # |   -8 Forget to print the answer modulo some number :D
 » 6 years ago, # | ← Rev. 2 →   +37 my silliest mistake was in APIO 2013 the problem robots , I spent a lot of my time debugging my solution without any success, after the contest I discovered that the obstacles in the input is 'x' (small one) while I was thinking it was 'X' (capital), I lost a bronze medal because of it :(
 » 6 years ago, # |   0 I used maxn = 501 instead of maxn = 5010 in COCI contest and got 42 points instead of 140.
 » 6 years ago, # |   +36 Factorizing 9: I wrote 9 = 3*3*3:/
•  » » 6 years ago, # ^ |   +1 I have a similar mistake...6!=5!*3!*2!9!=7!*(2!)^3*(3!)^2In Codeforces Round #292 Div. 1 Problem A :(And I used set > to solve Problem B and got TLE in system tests :(
 » 6 years ago, # |   +3 I locked my problem without checking it properly, and hello div.2
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   +67 lock problem see other's code find a test case that the outputs from two programs are different "Wow!+100!" unsuccessful hacking attempt failed system test
•  » » » 3 weeks ago, # ^ |   +5 You can hack yourself in this case
 » 6 years ago, # |   +23 NEERC ACM quarterfinal. There was two variables with the same name: string s; ... { string s; ... // using s as first s; } 
•  » » 6 years ago, # ^ |   +17 -Wshadow is your friend
•  » » 6 years ago, # ^ | ← Rev. 2 →   0 Same as you. It took about three hours to debug :|
 » 6 years ago, # |   0 I used an array of size 111*111 instead of 1111*1111 in div2 A problem and it was hacked in the last few seconds of the contest :/
 » 6 years ago, # |   +21 I once coded an offline solution for yet another problem "answer Q queries" and forgot to sort queries by index before printing the answer. I was debugging it for about 40 minutes. The entire code was correct except this missing sort. Of course, I used only one test case during debugging executions, so answer was correct every time.
 » 6 years ago, # |   -8 Forget to take absolute value sm = (a+b)-1 instead of sm = abs((a+b)-1), I found my mistake after I locked the problem
 » 6 years ago, # |   0 Yesterday in problem B I read numbers r and g and then r numbers and then g numbers. While I should read r and then r numbers, then g and g numbers...
 » 6 years ago, # | ← Rev. 2 →   0 Using 2000 as INF to initialize variable that contains smallest number when the range of answer was 1 — 10^6. (the small input range of answer was 1 — 10^2)
 » 6 years ago, # |   0 Now this case came in my mind. Three years ago in a Bulgarian competition one of the task was to print some triangles or rectangles with '*'. I solved it and then I got 0 points. I decided to test my solution myself and I saw that I have forgotten to put whitespace between the symbols and this cost me the second place :D
 » 6 years ago, # |   +3 Using int when long long was required. Getting overflow even when using long long. For example to check if a's sign and b's sign is different by multiplying them and comparing with -1. Using wrong initial values for max(0 when maximum element could be negative) or min variables(INT_MAX instead of 1e18). While copy pasting query and update function calls of segment trees, forgetting to change arguments. Wrongly inserting intial elements in a vector. push_back(some value) twice instead of just once. while(scanf("%d",&a)!=EOF) instead of while(scanf("%d",&a)) . Not using setprecision(9) when required. Using the local variable of the same name when global variable was required to be used. and many more.... :(
•  » » 6 years ago, # ^ |   0 "While copy pasting query and update function calls of segment trees, forgetting to change arguments"Not just it sometimes my update function calls the query function. And forgetting that +1 for right child B'(.
•  » » » 3 weeks ago, # ^ |   0 Write segment tree on half-open interval, and you will never ever forget about +1
 » 6 years ago, # |   0 It's not happened in codeforces' contest, but my silliest mistake is forgot to print newline character after the output (like what you did on your code!) (/.) I'm so sad...
 » 6 years ago, # |   +2 I have done couple of those recently. They might not be the silliest but they have made me crazy. I am really diffident about myself now. And feeling disappointed a lot. :(1) During round 291 div2, it took some time for me to be able to log into CF. When I finally logged in, I thought, "why not solve the problem C firstly and get more points?" So I opened problem C, coded it and submitted but failed in pretest. Then I realized that I understood the problem totally wrong. Then I went to problem A and B. Due to the failure in problem C, I got disheartened and it took some time and some submissions for me to solve A and B. After that I came back to problem C and coded it in a new approach. This time it passed pretests. But interestingly, most of the people failed to solve problem C (At most 180 solved it as far as I remember). My solution failed also. It got MLE at test #18. Many people faced the same verdict (or TLE) due to the pattern of the problem. So finally I realized that it was so silly of me to try to solve problem C first which was probably harder than problem D. -_-2) During the last round (292div2), I took a lot of time to solve problem C. You can check my submission. I used prime factorization and factorial concepts, and also did counting of prime factors. Finally I ended up with such huge code that took me upto 1 hour to solve the problem. I was so unhappy about that.When I went to see others' solutions, I felt so ashamed of myself. I got amazed to see those simple-small solutions of problem C. I was truly so much ashamed. I wished I could bang my head on the wall and break it. -____-These are the recent two unexpected scenarios that I had to face. But I have faced a lot more. CF is giving me hard time. Pretty hard time. I wish I could be a candidate master and go up to some level so that I can regain confidence and courage. Due to the worst contests, I cannot even feel normal. It is bad, really bad. :(
 » 6 years ago, # |   0 I needed a set of symmetrical letters. And I've included letters AHIMNOPTUVWXY :D
 » 6 years ago, # |   0 I've recently written if (a[i]>=0&&i=0)
•  » » 6 months ago, # ^ |   -35 That one is typical!
 » 6 years ago, # |   +1 forgot to set precision and ended up getting a wrong answer, after the contest just added setprecision and Ta-Dah Accepted.
 » 6 years ago, # |   +52 I didnt code anything wrong.It was like 15 seconds left.I uploaded the wrong file.
 » 6 years ago, # |   +16 Segment tree. Size of subtree in a char. (RE6 instead of OK)
 » 6 years ago, # |   +44 int pgcd(int a,int b) { return b==0?a:(b%a,a); } "Why the fuck pgcd(8,9) returns 8???"
•  » » 6 years ago, # ^ |   +16 -Wunused should help here
 » 6 years ago, # |   0 I keep a N defined to 10^5+e for declaring arrays but N was supposed to be 10^6 + e, I recieved hell lot of RE and I had to ask someone else to debug that code, I was ashamed of myself!
 » 6 years ago, # |   0 1: When i joined codeforces contest first time, i didn't know submitting a solution again skips old solution, so after passing pretests with correct solution, i made one more submission just to decrease execution time & memory resulting in loss of 50 points. :)2: declared a counter of type char instead of int ,resulted in passing of pretests and failing of system test. :)
 » 6 years ago, # | ← Rev. 2 →   0 use "%d", instead of "%I64d" for read/write long long.
 » 6 years ago, # |   +6 I subtracted 1 in a for loop from v.size(). Guess what happened when the input vector empty?
•  » » 6 years ago, # ^ | ← Rev. 2 →   +3 It became the maximum value of size_t since size_t is unsigned. I was trapped by this once too.So, I think we should compile our code with -Wall. Then we can receive a warning of comparison between signed and unsigned integer expressions.
•  » » » 6 years ago, # ^ |   0 (int)v.size()
 » 6 years ago, # |   -8 My fault was about limits too. After the contest i went to bathroom and come back. Added 2 '0' character to code then it was AC.
 » 6 years ago, # |   +31 for (int i = n - 1; i--; i >= 0) instead of: for (int i = n - 1; i >= 0; i--) It passed pretests and failed systests
•  » » 6 years ago, # ^ |   0 Wow. I guess that was pretty hard to find.
 » 6 years ago, # |   +3 Wrote alphabet 'l' instead of digit '1' in one of the loops and 'l' was a variable...
 » 6 years ago, # |   0 I forgot to change magnitude of gen-test from 10^1 to 10^5, and then I mis-hacked two times trying to call TLE http://codeforces.ru/contest/490/hacks/126123/test
 » 6 years ago, # |   +3 bool vis[MAXN]; bool dfs(int cur) { vis[cur] = 1; // some code to detect a cycle in a graph vis[cur] = 2; return 0; } Why the HELL no value equals 2?
 » 6 years ago, # |   0 if (xx >= n || xx < 0 || yy < 0 || xx >= m) continue; 9897544
 » 6 years ago, # |   0 using OR logic instead AND
 » 6 years ago, # |   0 used a float instead of double, got over flow after system test.
 » 6 years ago, # |   +11 24*1=1 is clearly the most stupid bug I have ever met :(And some other silly bugs: char n instead of int n My code to find set in Disjoint-Set: int find(int x) { if (lab[x]<0) return (x); return (lab[x]); lab[x]=find(lab[x]); }  Using c++ std::set (this may cause unexpected behavior): set s; for (set::iterator it=s.begin();it!=s.end();it++) { if (blablabla) s.erase(*it); }  Comparing bignum from last digit to first digit instead of first digit to last digit. Getting long long overflow (unsigned long long is ok) in 458B - Distributed Join, this made me lose a T-shirt :( Wrong time-complexity calculation: In 391C3 - The Tournament, I thought my algorithm was O(N^2logN), when it was only O(NlogN). I couldn't solve this problem during the contest and also lost a T-shirt :( Forget about multiple data sets in one input file. And many other bugs that I can't tell all of them.
 » 6 years ago, # |   +5 In a bulgarian competition awhile ago, the input consisted of n, followed be two arrays of numbers. My input was: n a1 b1 a2 b2 . . While it should've been: n a1 a2 a3... b1 b2 b3... Of course, the problem had no feedback and the sample test case was somethint like: 2 1 0 0 1 I made a test generator with a slow solution, but my generator was producing the input in the wrong way too. Got 10 instead of 100 points for the problem.
 » 6 years ago, # |   0 The most common mistake for my case is that I use integer instead of long long or unsigned long long.
 » 6 years ago, # |   0 I forgot to add memset in a solution that contained test cases and debugged it for hours and finally had to ask it here on the blog !!!
 » 6 years ago, # |   0 I was about to become red, but failed systests. I used somthing like this: vector v; ... for (int i = v[0]; i <= n; i++) { } Got RE on systests. Adding the line (or using simple array) if (!v.empty()) { ... } got accepted.
 » 6 years ago, # |   +8 vector values; ... double sum = accumulate(values.begin(), values.end(), 0); 
 » 6 years ago, # |   0 In one of the question of heap, we were supposed to check whether a number is a power of two or not. Our team wasted around 30 minutes in if(i&(i-1) == 0) { cout<<"Power of two"; } else { cout<<"Not a power of two"; } which were the last 30 minutes of ACM-ICPC Regionals :P and as soon as the contest got over, we figured out that the condition must be if( (i&(i-1)) == 0) X-(
•  » » 4 months ago, # ^ |   0 Can you explain what is the difference ? I don't get it.
•  » » » 4 months ago, # ^ | ← Rev. 2 →   0 == has higher precedence than &, so the expression i & (i - 1) == 0 is evaluated as i & ((i - 1) == 0). See this.
•  » » » » 4 months ago, # ^ |   0 Thanks alwyn.
 » 6 years ago, # | ← Rev. 4 →   0 After looking an Editorial which metioned using long long and map,since pascal(the programming language I have used) doesn't have map,I tried to solve this problem using binary search instead of map.Generally I succeeded,but I didn't use long long(or int64 in pascal).. Sorry for the bad English:D
 » 6 years ago, # |   0 In GCJ 2014 I lost a T-Shirt due to the following stupid mistake. ^^java Program -Xss8MVerdict: StackOverflowInstead of: java -Xss8M ProgramVerdict: Accepted
 » 3 years ago, # |   +4 I've made many stupid mistakes over the years. Like taking int where long long is needed, not initializing or clearing containers like vectors, arrays, map etc. But the one I remember now is forgetting to comment out a output line used for debugging. It was hiding inside a condition and no testcase was using that condition, Alas! But I learned a great thing after that. You can use "cerr" for debugging purpose. I think, every mistake is a step towards learning something new and interesting.
 » 3 years ago, # |   +75 Once I noticed my code was wrong on n=1 and was printing 100 instead of 0.So I added a line like this: if(n==1) print 100;
 » 3 years ago, # |   +7 I assumed, that 1 is a prime number
 » 3 years ago, # |   +3 I once commented out all my debugging outputs but forgot about the loops causing my solution to build a sparse table 10^10 times.
 » 3 years ago, # |   0 my silliest mistake was In Problem When I Read Problem As We Need To Check Equal Consecutive Elements and Make Operations on Them...While Problem Was To Check Equal Elements (Maybe not Consecutive) and Make on Them Operations
 » 3 years ago, # |   +86 Was solving an almost-tree problem. Wrote a lot of comments in the code, including a comment about running Floyd-Warshall. Finished the code. WA every time. An hour of debugging. No results.Then I realized that I didn't actually write Floyd-Warshall, I just wrote the comment. Genius.
•  » » 3 years ago, # ^ |   0 A big HAHA
 » 3 years ago, # |   +3 It may be scanf("%d" , x).
•  » » 2 years ago, # ^ |   0 And printf("%d\n",&ans);
 » 3 years ago, # |   +3 write a condition for n=1 separately because lots of hacks were there and I was happy that now I will get a chance to hack. if(n==1) cout<<"0\n"; After that I locked my submission then my solution got hacked because at n==1 we have to print 1. -_-
 » 3 years ago, # |   +12 I considered 'y' as a consonant.
 » 3 years ago, # |   0 if (STR[i] == 0) { // do something }Where STR is string.(you can understand what's wrong).It's my mistake in problem E. (E is something that you want to solve in running contest.)Feel bad.
 » 3 years ago, # |   0 Sometimes, we've to print something and get to return out of main.So, I generally use return cout<<"YES",0;But in haste, I forgot to use the keyword return, and got -50 to correct it.
 » 3 years ago, # |   +43 I didn't read all the problems.
 » 3 years ago, # |   0 On the previous div3 i used binary search in C problem but i forgot to sort the vector so i had been searching for mistake for 30 minutes, but i solved it, though.
 » 3 years ago, # |   0 In a past contest long ago, my program computed the answer correctly but I output wrong variable. It passed the pretest but failed on system test, I only realized my mistake after the contest.
 » 3 years ago, # |   +3 Today's Div3 declare size of array 1e5 instead 2e5
 » 3 years ago, # | ← Rev. 2 →   +3 I've done this more than once: while (!q.isEmpty()) { int cur = in.nextInt(); // instead of q.poll() =( } 
 » 3 years ago, # | ← Rev. 2 →   0 Once I was implementing LCA function which needs matrix par[v][log v] for storing every 2i th ancestor of each vertex from 1 to v.I declared my parent's matrix as int par[maxv][maxlog], while using it like par[log][vertex] .The silly mistake took me about 5 hours before getting detected!
 » 3 years ago, # |   +10 i modded the answer by 1e9+7 when there was no needed to print the answer modulo 1e9+7
 » 3 years ago, # |   +14 Participating in it?
 » 3 years ago, # |   +5 Instead of printing NO I printed N0.
 » 3 years ago, # |   +11 Writing const int mod = 10^9 + 7; as module for hashes on ACM quarterfinal. Half an hour of debugging then, cause i was not even looking on part of the code where i needed hashes (just like my teammates), i believed it to be correct.
 » 3 years ago, # | ← Rev. 3 →   +3 I used lower_bound(s.begin(),s.end(),x) instead of s.lower_bound(x), where s is a set. Didn't know the former is O(n).
 » 3 years ago, # |   +3 Once I wanted to check if a variable is 1, and by default I wrote an if statement like if(x != 0)but that x could be 2, 3 and so on.. Lost AC because of that
 » 3 years ago, # |   0 On Edu round #47, something like this: int a[n]; and later ... if(ai > n) break; else //do sth with a[ai]">" is not ">=" ... I noticed the mistake right away but the penalty was 10 minutes.
 » 3 years ago, # | ← Rev. 2 →   +8 One year ago on all-russian school students olympiad I had struct block. Something like that:struct block { int len, number, ...; };And I have std::set with compare block1.len < block2.len. So, set delete all blocks with the same length.The most interesting that it solved first subgroup, so it was hard for me to find mistake(
 » 2 years ago, # |   +4 One of my friends once accidentally wrote int t = scanf("%d", &t);
 » 2 years ago, # | ← Rev. 3 →   0 I did it in today's contest in this problem. //outside of bfs loop int x,y; cin>>x>>y; while(sz(pq)){ //inside of bfs loop int x=cur_row; int y=cur_col; // then checking against these local variables thinking that I am checking against the //variables i have declared outside of the loop; } The sad part is that I could not find this bug for one hour and contest ended and i couldnot submit d.
 » 2 years ago, # |   -8 Wrote a & b instead of a % b... took me 2 hours to find the bug (by then contest ended).
 » 6 months ago, # |   +3 Using ! instead of ~.
 » 4 months ago, # |   0 In a fenwick tree question I declared the array size by 1 less than required which got my solution to fail in system testing.
 » 4 months ago, # | ← Rev. 2 →   0 In a recent div 2 started a loop from 1 instead of 0 ... Got 4 wa.. only to realise this just seconds after contest ended :(
 » 4 months ago, # |   +7 I missed Gold in EJOI 2019 because I forgot to #define endl '\n', still regret it
 » 4 months ago, # |   0 Я оставил код который я не мог не как написать и пошёл гулять прихожу я смотою над самой глупой ошибкой я написал deb вместо def (для тех у кого python) :) :D ;)
•  » » 4 months ago, # ^ |   0 It's russian meme if u dont know :)
 » 4 months ago, # |   +3 ll s1,s2;cin>>s1>>s1; totally went from some random string error to AC after contest.
 » 4 months ago, # |   +5 Thinking that the first submitted solution might fail system tests so submitting the 2nd solution when the contest is about to end and converting +70 to -20. And then seeing my first solution passing all test cases.
 » 4 months ago, # |   -6 When trying to find the union of ranges, I'm supposed to first sort the ranges. I may sort them based on the left value or I may sort them based on the right value. //possibility 1 bool comp(pair a, pair b){ return a.first a, pair b){ return a.second a, pair b){ return a.first
 » 4 months ago, # |   +10 One state of my DP function could hold values from 0-3. So I declared DP table as DP[..][..][3].
 » 4 months ago, # |   0 1.had to traverse from a-z....i used ""for(i=0;i<25;i++){ll ss=i-'a';........}""....even in contest time i couldnot figure out the problem....i find it after contest....... 2.infinity=1e12...(where some results was bigger than that)3.not calling seive function....(still pretests was passed) and then wrong answer on test case 2etc.......
 » 4 months ago, # |   0 In my second last contest i was accessing n — 1 th index of n — 1 sized vector. This mistake ruined the contest for me.
 » 4 months ago, # | ← Rev. 4 →   +10 Once when I make a segment tree  ll query(int l, int r, int ct, int lt, int rt) { if (lt >= r || l >= rt) return 0; /// Out-range if (lt >= l && r >= rt) return t[ct]; /// In-range int mt = (lt + rt) >> 1; /// Midle return query(l, r, ct * 2 + 1, lt, mt); /// <---------------- + query(l, r, ct * 2 + 2, mt, rt); } and once I use modulo where as the answer fit long long type
 » 4 months ago, # |   0 In Segment Trees: if (r < lc[p] || lc[p] > r) return; // should be if (r < lc[p] || l > rc[p]) return; 
 » 4 months ago, # | ← Rev. 2 →   +25 In the Singapore NOI this year, one of the problems involved making a segment tree on the difference array $D$ of another array $A$.When the size of array $A$ is 1, the difference array $D$ is of size 0.. which means the segment tree would infinitely recurse because segment size is 1 (the base case) would never be fulfilled for any node in the tree...I spent almost 2 hours trying to debug this, failed to debug it for the entire time, and ended up one rank away from the gold medal...
 » 4 months ago, # |   +1 Used python
 » 4 months ago, # |   0 I have got Segmentation Fault a few times (mostly in dp problems) because I forgot to change it's maximum size.
 » 4 months ago, # |   0 When I was writing the code, I missed one header file, which cost me a full 400 points.
 » 2 months ago, # | ← Rev. 2 →   0 Recently, forgot to remove unneeded stuffs in the code that reduce the run time. It is already sorted but I sort it again to make sure but slow down the program significantlyOh my stupid make me lose 1 point to be an Expert haha ;-;
 » 2 months ago, # |   +2 while (some condition); 
 » 2 months ago, # |   +1 Mistyped an 'j' as an 'i' and spent the next hour debugging my code but was only able to find my mistake after contest ended because those two characters look awfully simmiliar
 » 2 months ago, # |   0 This was from a while ago but I'm still kinda mad about it.
 » 2 months ago, # |   0 froepen("call.in", "r", stdin); :(
 » 3 weeks ago, # |   +2 in today's contest(29/12/2020), instead of using goto to input the next testcase, I mistakenly used return 0, realized it 10 second before the contest was going to end, still couldn't fix it in time, code was AC afterwards.Yeah, I found this blog just to vent >_<
•  » » 3 weeks ago, # ^ |   +2 Write functions instead.
•  » » 3 weeks ago, # ^ |   0 So now you understand why most of the people use a 'solve()' function and call it for each test case from main()
 » 3 weeks ago, # |   +5 misspelling "impossible" as "impossibe" and spending almost an hour debugging
 » 3 weeks ago, # |   0 Cue every single time I failed system tests due to int overflow...
•  » » 3 weeks ago, # ^ | ← Rev. 3 →   -26 #define int long long 
•  » » » 3 weeks ago, # ^ |   0 yep that's part of my template now :/
 » 3 weeks ago, # | ← Rev. 2 →   -7 In Codeforces global round 11, I mentally solved B,D,E (In fact they are the same as the editorial solutions) but was able to implement none of them because on B I have an error with flags that I couldn't debug, and I just somehow couldn't implement D or E in 90 minutes...I also have a lot of overflow and typoes. For me, most of the times implementing is much harder than solving.
 » 3 weeks ago, # |   +2 Getting the input in the wrong format and debugging my code for hours :)
•  » » 3 weeks ago, # ^ | ← Rev. 2 →   +1 Wrong format in output twice: AGC051B Same problemPrinting 1000 gives this
 » 3 weeks ago, # |   0 I was gonna write s.substr(0,4) but instead wrote s.substr(0.4). And it got compiled successfully (welcome to C++). I didn't notice what was wrong until the next day.
 » 3 weeks ago, # |   0 It was in a rated contest. I misread the problem and therefore added an unneeded edge case. I forgot to print a new line in the edge case, which caused by program to WA. I didn't realize the mistake in-contest but had I removed the edge-case code or printed a new line, I would have ACed. Furthermore, as my luck had it, this problem was rated 1500, and my rating at the time was 1300 (I would've had a huge rating boost had I gotten it right).
 » 3 weeks ago, # |   +4 Instead of 1LL<
 » 3 weeks ago, # |   +1 Binary searched over the range (1, i — 1) instead of (1, i) ._.
 » 3 weeks ago, # |   +1 used >0 instead of >=0 got WA 2 times then realised this mistake but by this time the game was over.
 » 3 weeks ago, # |   0 Summary: -Wall saves your life
 » 3 weeks ago, # |   0 1.not changing line. 2.i didn't knew that input with spaces can be accepted using cin>>a>>b. These are some of silliest mistakes i had done.
 » 3 weeks ago, # |   0 i wrote if(s[i]==0) instead of if(s[i]=='0') realizing this after 1hr
 » 3 weeks ago, # |   0 In one of the recent contest i was quite sure about my idea but it was giving wrong answer, After an hour i figured out that i have not put the break condition in one the loop, later it give Ac after putting it.
 » 3 weeks ago, # |   0 I few months back, i wrote if(f&1&&k==5) instead of if((f&1)&&(k==5)).
 » 3 weeks ago, # |   0 Not reading the constraints.
 » 3 weeks ago, # |   0 forgot to register
 » 3 weeks ago, # |   +2
 » 3 weeks ago, # |   0 eating 2 shawarmas before the contest
 » 3 weeks ago, # |   0 Some mistakes made by me:1.redefine the variable (It happened many times to me before.)For example, I wrote code such that: #include using namespace std; int n,m; void solve() { //... //something which uses n and m } int main() { int n,m; cin>>n>>m;//which uses n and m defined in the main function solve(); return 0; } 2.define a function such that int Min(int n,int m) but n and m can be 64-bit signed integers3.use define incorrectly such that define min(a,b) ((a)<(b)?(a):(b))If a is a function, it will call the function twice.If a is a recursion function, it will call the function $2^k$ times. ($k$ is the number of plies)4.modulo $P$ anywhere except when printing the answer: //a=(...)%P; //b=(...)%P; printf("%d\n",a+b); 5.forget that some functions with return values like size() are unsigned: for(int i=0;i>T; while(T--) { int n,m; cin>>n>>m; if(n<=2||m<=2) { puts("-1"); break;//here should be "continue" } //... } 7.forget to clear the array when there are two or more test cases( so please clear it in time and double samples to test your program )8.clear the array in time but get TLEFor example, you are given $n$ integers in the range $[0,10^6]$ and asked if $x$ appears for some integers $x$. There are $10^4$ test cases and it is guaranteed that $\sum n$ doesn't exceed $10^6$.It is obvious that we need a bool array vis` to record whether one integer appears. But if you clear the whole array every time, you will get TLE because it is too slow. We should also record the positions we visit so that we can just restore these elements. In fact, in this example, we don't need to record it because we can easily know the elements we visit (which are just we are given).
 » 3 weeks ago, # |   0 I lost a lot of time just because of this __gcd(0,0) :V