Submission #80028

#TimeUsernameProblemLanguageResultExecution timeMemory
80028abra_stoneJOIOJI (JOI14_joioji)C++14
100 / 100
65 ms8896 KiB
#include <iostream> #include <cstdio> #include <map> #define PII pair<int, int> using namespace std; int n, mx, cj, co, ci; string a; PII t; map<PII, int> m; int main() { int i; cin >> n >> a; a = '_' + a; cj = co = ci = 0; m[{0, 0}] = 0; for (i = 1; i <= n; i++) { if (a[i] == 'J') cj++; else if (a[i] == 'O') co++; else ci++; t = {cj - co, cj - ci}; if (!m.count(t)) m[t] = i; else mx = max(mx, i - m[t]); } cout << mx << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...