Submission #156042

# Submission time Handle Problem Language Result Execution time Memory
156042 2019-10-03T02:10:37 Z manh9203 JOIOJI (JOI14_joioji) C++17
5 / 100
55 ms 6264 KB
#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

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 time Memory Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 2 ms 504 KB Output is correct
7 Correct 2 ms 504 KB Output is correct
8 Correct 3 ms 496 KB Output is correct
9 Incorrect 3 ms 504 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 9 ms 1272 KB Output is correct
3 Correct 14 ms 2040 KB Output is correct
4 Correct 25 ms 3444 KB Output is correct
5 Correct 39 ms 5232 KB Output is correct
6 Correct 51 ms 5800 KB Output is correct
7 Incorrect 55 ms 6264 KB Output isn't correct
8 Halted 0 ms 0 KB -