Submission #555545

#TimeUsernameProblemLanguageResultExecution timeMemory
555545fuad27Nekameleoni (COCI15_nekameleoni)C++17
28 / 140
3038 ms6108 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 5010; const int MAXK = 50; long long k; vector<long long> pref[50]; bool check(int l, int r) { bool c = true; for(int i = 0;i<k;i++) { if(!(pref[i][r+1] - pref[i][l]))c = false; } return c; } int main () { long long n, m; cin >> n >> k >> m; for(int i = 0;i<50;i++) { pref[i].resize(MAXN); } long long arr[n]; for(int i = 0;i<n;i++){ cin >> arr[i]; arr[i]--; } for(int i = 0;i<50;i++) { pref[i][0] = 0; for(int j = 1;j<=n;j++) { if(arr[j-1] == i) { pref[i][j] = pref[i][j-1]+1; } else pref[i][j] = pref[i][j-1]; } } while(m--) { int type; cin >> type; if(type == 1) { int p, v; cin >> p >> v; v--;p--; arr[p] = v; for(int i = 0;i<50;i++) { pref[i][0] = 0; for(int j = 1;j<=n;j++) { if(arr[j-1] == i) { pref[i][j] = pref[i][j-1]+1; } else pref[i][j] = pref[i][j-1]; } } } else { int p1 = 0, p2 = 0; long long ans = 1e9; while(p2 < n) { if(check(p1, p2)) { ans = min(ans, (long long)p2-p1+1); p1++; } else { p2++; } } if(ans == 1e9)ans = -1; cout << ans << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...