Submission #61488

#TimeUsernameProblemLanguageResultExecution timeMemory
61488sean617JOIOJI (JOI14_joioji)C++98
100 / 100
107 ms12384 KiB
#include <iostream> #include <cstdio> #include <set> #include <map> #define PI pair<int, int> using namespace std; int n, l, r, md, ans, mx, s[3][200005]; set<PI> v; map<PI, int> b1; string a; int main() { int i, z, t1, t2; cin >> n; cin >> a; a = ' ' + a; for (i = 1; i <= n;i++) { s[0][i] = s[0][i - 1]; s[1][i] = s[1][i - 1]; s[2][i] = s[2][i - 1]; if (a[i] == 'J') s[0][i]++; else if (a[i] == 'O') s[1][i]++; else s[2][i]++; } v.insert(PI(n, n)); b1[PI(n, n)] = 0; for (i = 1; i <= n; i++) { t1 = s[0][i] - s[1][i] + n; t2 = s[1][i] - s[2][i] + n; if (v.count(PI(t1, t2)) == 0) { v.insert(PI(t1, t2)); b1[PI(t1, t2)] = i; } else { mx = max(mx, i - b1[PI(t1, t2)]); } } cout << mx; return 0; }

Compilation message (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:14:9: warning: unused variable 'z' [-Wunused-variable]
  int i, z, t1, t2;
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...