rinku11's blog

By rinku11, history, 2 years ago, In English

Here is the question link which I solved-:https://codeforces.com/contest/1617/problem/A Here is my submission code-:https://codeforces.com/contest/1617/my After going to this link plz go to the latest submission to see my code.

This code works fine in all other IDE (CodeChef,VsCode,Hackerrank) .But when I submit my code on codeforces running contest it gives me errors. Plz, anybody help me out.

  • Vote: I like it
  • -21
  • Vote: I do not like it

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

If you have such problems, it means your code contains undefined behavior. To figure out where, compile your code with sanitization flags. Here, I did it for you:

Output

Signed integer overflow on line 29. Oh look, you never initialize the variables cnt1, cnt2, cnt3. They are NOT guaranteed to be initialized to 0. They are filled with garbage so you get nonsense output.