Блог пользователя BishalG

Автор BishalG, 11 лет назад, По-английски

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

My Submitted code: [submission:http://codeforces.net/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.

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
11 лет назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

In my PC, it said '2'.

»
11 лет назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

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

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

»
11 лет назад, # |
  Проголосовать: нравится +25 Проголосовать: не нравится

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
»
11 лет назад, # |
Rev. 2   Проголосовать: нравится +2 Проголосовать: не нравится

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

»
11 лет назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

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.