Is there any problem with codeforces code testng?

Правка en2, от 5-gon, 2022-06-11 08:41:53

I was solving a problem in CF. So, I came up with an idea(don't know if it would work for sure)..I implemented the code. While I was testing the sample input..it successfully passed! But when I submit the problem, the sample didn't passed. Then I tested it in the CF custom testing but it showed me the same result that the sample test cases failed! But my editor showed me that all samples passed. So, I tested it on codechef editor & online c++ compiler. They showed me my test cases passed! Don't understand what happened! Is there any issue on CF compiler or testing?

Problem link: 701C - They Are Everywhere

My Code ->

include <bits/stdc++.h>

using namespace std; void test_case() { int n;

cin >> n; string s; cin >> s; set ss; for (int i = 0; i < n; ++i) { ss.insert(s[i]); } int unique = (int)ss.size(); vector vis(26, false); vector num_unique(n+1); num_unique[0] = 0; for (int i = 0; i < n; ++i) { if (!vis[s[i]]) { num_unique[i+1] = num_unique[i] + 1; vis[s[i]] = true; } else { num_unique[i+1] = num_unique[i]; } } int i = 1, j = n, maxi = 0, ans = 0; while (i <= j) { int dist = num_unique[j]-num_unique[i]; if (dist >= maxi) { maxi = dist; ans = j-i+1; } if (i+1 < n+1 && num_unique[i+1] == num_unique[i]) { ++i; } else if (j-1 > i && num_unique[j-1] == num_unique[j]) { --j; } else { ++i; } } cout << ans << '\n'; } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false), cin.tie(nullptr); int tc = 1; // cin >> tc; while (tc--) { test_case(); } return 0; }

The input - 7 bcAAcbc

The real output - 3

The output showed me — 2

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский 5-gon 2022-06-21 11:27:34 1
en3 Английский 5-gon 2022-06-11 08:44:01 1087
en2 Английский 5-gon 2022-06-11 08:41:53 2 Tiny change: ' int n;\n cin >>' -> ' int n;\n\n cin >>'
en1 Английский 5-gon 2022-06-11 08:39:51 1846 Initial revision (published)