Submission #156042

#TimeUsernameProblemLanguageResultExecution timeMemory
156042manh9203JOIOJI (JOI14_joioji)C++17
5 / 100
55 ms6264 KiB
#include<bits/stdc++.h> using namespace std; const long long base = 311; const long long mod = 1311322777; const int N = 2e5 + 5; int n,sum[N][3],ans; map<long long,int> check; string s; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> s; s = " " + s; for(int i=1;i<=n;i++){ sum[i][1] = sum[i-1][1]; if(s[i] == 'J') sum[i][1]++; sum[i][2] = sum[i-1][2]; if(s[i] == 'O') sum[i][2]++; sum[i][3] = sum[i-1][3]; if(s[i] == 'I') sum[i][3]++; if(sum[i][1] == sum[i][2] && sum[i][2] == sum[i][3]){ ans = max(ans, i); } long long haS = 0; haS = (haS*base + sum[i][2]-sum[i][1]) % mod; haS = (haS*base + sum[i][3]-sum[i][2]) % mod; if(check[haS] == 0){ check[haS] = i; }else{ ans = max(ans, i-check[haS]); } } cout << ans; }

Compilation message (stderr)

joioji.cpp: In function 'int main()':
joioji.cpp:16:25: warning: array subscript is above array bounds [-Warray-bounds]
   sum[i][3] = sum[i-1][3]; if(s[i] == 'I') sum[i][3]++;
               ~~~~~~~~~~^
joioji.cpp:16:11: warning: array subscript is above array bounds [-Warray-bounds]
   sum[i][3] = sum[i-1][3]; if(s[i] == 'I') sum[i][3]++;
   ~~~~~~~~^
joioji.cpp:16:52: warning: array subscript is above array bounds [-Warray-bounds]
   sum[i][3] = sum[i-1][3]; if(s[i] == 'I') sum[i][3]++;
                                            ~~~~~~~~^
joioji.cpp:17:53: warning: array subscript is above array bounds [-Warray-bounds]
   if(sum[i][1] == sum[i][2] && sum[i][2] == sum[i][3]){
                                             ~~~~~~~~^
joioji.cpp:22:29: warning: array subscript is above array bounds [-Warray-bounds]
   haS = (haS*base + sum[i][3]-sum[i][2]) % mod;
                     ~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...