Submission #555618

# Submission time Handle Problem Language Result Execution time Memory
555618 2022-05-01T09:30:14 Z Fidan Nekameleoni (COCI15_nekameleoni) C++17
42 / 140
3000 ms 41940 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN=400010;
const ll inf=(1e18);
int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	ll n, k, m, i, j;
	cin>>n>>k>>m;
	vector<ll> v(n+1, k+10);
	vector<vector<ll>> dp(k+1, vector<ll> (n+1, 0));
	for(ll i=1; i<=n; i++){ 
		cin>>v[i];
	}
	for(i=1; i<=k; i++){
		for(j=1; j<=n; j++){
			if(i==v[j]){
				dp[i][j]=dp[i][j-1]+1;
			}
			else {
				dp[i][j]=dp[i][j-1];
			}
		}
	}
	while(m--){
		ll test;
		cin>>test;
		if(test==1){
			ll p, val;
			cin>>p>>val;
			for(i=p; i<=n; i++){
				dp[v[p]][i]--;
			}
			v[p]=val;
			for(i=p; i<=n; i++){
				dp[v[p]][i]++;
			}
		}
		else {
			ll l=0, r=k, cavab=n+100;
			while(r<=n){
				bool f=true;
				if(r-l<k){
					r++;
					continue;
				}
				for(ll i=1; i<=k; i++){
					if(dp[i][r]-dp[i][l]==0){
						f=false;
					}
				}
				if(f){
					cavab=min(cavab, r-l);
					l++;
				}
				else {
					r++;
				}
			}
			if(cavab==n+100){
				cout<<-1<<endl;
			}
			else {
				cout<<cavab<<endl;
			}
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 140 ms 816 KB Output is correct
2 Correct 75 ms 816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 415 ms 1532 KB Output is correct
2 Correct 161 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 891 ms 2436 KB Output is correct
2 Correct 300 ms 2440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3089 ms 8788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3067 ms 22944 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3082 ms 17492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3083 ms 27468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3084 ms 25528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3091 ms 41940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3090 ms 41872 KB Time limit exceeded
2 Halted 0 ms 0 KB -