Codeforces и Polygon могут быть недоступны в период с 6 декабря, 22:00 (МСК) по 7 декабря, 00:00 (МСК) в связи с проведением технических работ. ×

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

Автор dsarules, история, 4 недели назад, По-английски

I tried submitting a solution to https://codeforces.net/contest/1820/problem/C, and for the first test case, my ide gave the correct solution. However, when I submitted the code to codeforces, it says that my output for the last test case was "YES", despite how the ide says that the output was "NO". Why is this happening?

The ide link is: https://ide.usaco.guide/OAoVexwMwTGAif_Fi8T.

The submission link is https://codeforces.net/contest/1820/submission/289843533.

Thank you!

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

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

It seems that in the last test, you are accessing to k[v[i]]-- when $$$i=-1$$$. In the line 35:

for (int i=firstoneranges[0];i<=firstoneranges[1];i++) {
   k[curr]++;
   k[v[i]]--;
}

You can debug this kind of things in custom invocation section, at the end of contest sections.