Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

BishalG's blog

By BishalG, 10 years ago, In English

Hoping for good response from all coders. PROBLEM: http://codeforces.com/contest/387/problem/C

My Submitted code: [submission:http://codeforces.com/contest/387/submission/5861759]

Although, my code is running fine & showing right output to given testcases. But, Codeforces says that this code is giving another output.How could be this possible? It would be great help if someone says, what is the output generated my my code to their PC?

And, I want to codeforces authority to look at to this issue carefully.

Thanks in advance.

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

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

In my PC, it said '2'.

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

Take a look. http://codeforces.com/contest/387/submission/5861989

UPD. You should never write something like that for a string: for(int i=0; a[i]; i++)

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

You have multiple errors in your code:

  • x.cpp: In function 'bool operator<(std::string, std::string)':
    x.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
  • You can't do for(int i=0; a[i]; i++) like vas.and.tor noted, do for (int i = 0; i < a.size(); i++) instead
  • Your operator < will return true if strings are equal
  • There is already a operator < for strings, are you sure your version is used?
  • You have out-of-bounds array access in if(s[i+1]=='0') in two places
»
10 years ago, # |
Rev. 2   Vote: I like it +2 Vote: I do not like it

Thanks @Damon , vas.and.tor and andreyv for help.

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

I would recommend to debug it on Codeforces servers using customtest feature. Make some debug output and try to find out where does it work differently.