Submission #1041899

# Submission time Handle Problem Language Result Execution time Memory
1041899 2024-08-02T09:38:53 Z vjudge1 Nekameleoni (COCI15_nekameleoni) C++17
42 / 140
3000 ms 20828 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n,k,m;
	cin>>n>>k>>m;
	int pre[n+1][k]={},a[n+1];
	for (int i=0;i<n;i++)
	{
		cin>>a[i+1];
		a[i+1]--;
		for (int j=0;j<k;j++)
			pre[i+1][j]=pre[i][j];
		pre[i+1][a[i+1]]++;
	}
	while (m--)
	{
		int t;
		cin>>t;
		if (t==1)
		{
			int p,x;
			cin>>p>>x;
			x--;
			for (int i=p;i<=n;i++)
				pre[i][a[p]]--,pre[i][x]++;
			a[p]=x;
		}
		else
		{
			int s=0,e=n+1;
			while (s+1<e)
			{
				int mid=(s+e)/2;
				bool b=0;
				for (int i=0;i+mid<=n && !b;i++)
				{
					int ct=0;
					for (int j=0;j<k;j++)
						ct+=(pre[i+mid][j]-pre[i][j]>0);
					if (ct==k)
						b=1;
				}
				if (b)
					e=mid;
				else
					s=mid;
			}
			if (e==n+1)
				e=-1;
			cout<<e<<endl;
		}
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 155 ms 604 KB Output is correct
2 Correct 15 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 627 ms 860 KB Output is correct
2 Correct 52 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1490 ms 1620 KB Output is correct
2 Correct 111 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3049 ms 4696 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3020 ms 11612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3061 ms 9052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3054 ms 13728 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3048 ms 12748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3040 ms 20824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3064 ms 20828 KB Time limit exceeded
2 Halted 0 ms 0 KB -