Submission #555537

#TimeUsernameProblemLanguageResultExecution timeMemory
555537fuad27Nekameleoni (COCI15_nekameleoni)C++17
14 / 140
3075 ms4300 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN = 5010; const int MAXK = 50; vector<int> fen[50]; void update(int in, int val, int bt) { in++; while(in < MAXN) { fen[bt][in]+=val; in+=in&(-in); } } long long query(int l, int bt) { l++; long long sum = 0; while(l > 0) { sum+=fen[bt][l]; l-=l&(-l); } return sum; } long long k; bool check(int l, int r) { bool c = true; for(int i = 0;i<k;i++) { if(!(query(r, i) - query(l-1, i)))c = false; } return c; } int main () { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, m; cin >> n >> k >> m; for(int i = 0;i<50;i++) { fen[i].resize(MAXN); } long long arr[n]; for(int i = 0;i<n;i++){ cin >> arr[i]; arr[i]--; } for(int i = 0;i<n;i++) { update(i, 1, arr[i]); } while(m--) { int type; cin >> type; if(type == 1) { int p, v; cin >> p >> v; v--;p--; update(p, -1, arr[p]); arr[p] = v; update(p, 1, arr[p]); } 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...