Submission #156033

# Submission time Handle Problem Language Result Execution time Memory
156033 2019-10-03T01:17:08 Z puppies_and_rainbows JOIOJI (JOI14_joioji) C++14
100 / 100
93 ms 7304 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

map<int, int> a;
int n;
string s;
int hashed[200005];
int cj, co, ci;

int lel(int x, int y, int z)
{
	int ax=min(x, min(y,z));
	x-=ax, y-=ax, z-=ax;
	return x*200000*200000+y*200000+z;
}

signed main()
{
	cin>>n;
	cin>>s;
	for(int i=0; i<n; i++)
	{
		if(s[i]=='J')
		{
			cj++;
		}
		if(s[i]=='O')
		{
			co++;
		}
		if(s[i]=='I')
		{
			ci++;
		}
		hashed[i]=lel(ci,co,cj);
		a[hashed[i]]=1000000000;
	}
	for(int i=n-1; i>=0; i--)
	{
		a[hashed[i]]=min(a[hashed[i]], i);
	}
	a[0]=-1;
	int ans=0;
	for(int i=0; i<n; i++)
	{
		ans=max(ans, i-a[hashed[i]]);
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 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 256 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 256 KB Output is correct
11 Correct 2 ms 256 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 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 632 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 632 KB Output is correct
2 Correct 14 ms 1144 KB Output is correct
3 Correct 22 ms 1784 KB Output is correct
4 Correct 42 ms 2944 KB Output is correct
5 Correct 65 ms 4488 KB Output is correct
6 Correct 86 ms 5128 KB Output is correct
7 Correct 93 ms 5484 KB Output is correct
8 Correct 84 ms 4872 KB Output is correct
9 Correct 92 ms 5256 KB Output is correct
10 Correct 86 ms 5000 KB Output is correct
11 Correct 66 ms 6408 KB Output is correct
12 Correct 54 ms 3592 KB Output is correct
13 Correct 49 ms 3080 KB Output is correct
14 Correct 67 ms 7304 KB Output is correct
15 Correct 46 ms 2768 KB Output is correct