Submission #156040

#TimeUsernameProblemLanguageResultExecution timeMemory
156040Flying_dragon_02JOIOJI (JOI14_joioji)C++14
100 / 100
65 ms6120 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef pair<int, int> ii; const int mod = 1e9 + 7; const int inf = 1e9; int add(int x, int y) { return (1ll * x + 1ll * y) % mod; } int del(int x, int y) { return ((1ll * x - 1ll * y) % mod + mod) % mod; } int mul(int x, int y) { return (1ll * x * 1ll * y) % mod; } map<pair<int, ii>, int> mymap; int sum1, sum2, sum3, n; string s; int main() { cin.tie(0), ios_base::sync_with_stdio(0); cin >> n; cin >> s; s = "+" + s; mymap[{0, {0, 0}}] = 0; int ans = 0; for(int i = 1; i <= n; i++) { if(s[i] == 'J') sum1++; else if(s[i] == 'O') sum2++; else sum3++; int lmao1 = sum1, lmao2 = sum2, lmao3 = sum3; lmao1 -= min(min(sum1, sum2), sum3); lmao2 -= min(min(sum1, sum2), sum3); lmao3 -= min(min(sum1, sum2), sum3); //cout << lmao1 << " " << lmao2 << " " << lmao3 << " " << mymap.count({lmao1, {lmao2, lmao3}}) << "\n"; if(mymap.count({lmao1, {lmao2, lmao3}})) ans = max(ans, i - mymap[{lmao1, {lmao2, lmao3}}]); if(mymap.count({lmao1, {lmao2, lmao3}}) == 0) mymap[{lmao1, {lmao2, lmao3}}] = i; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...