Submission #484267

#TimeUsernameProblemLanguageResultExecution timeMemory
484267nickmet2004Lottery (CEOI18_lot)C++11
0 / 100
236 ms640 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e4 + 5; int n , l , a[N] , c[N]; int Q[N]; vector<int> B[N]; int main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> l; for(int i = 1; i <= n; ++i) cin >> a[i]; int q; cin >> q; for(int i = 0; i < q; ++i) cin >> Q[i]; if(q == 1 && Q[0] == 0){ memset(c , -1 , sizeof(c)); for(int i = 1; i <= n - l + 1; ++i){ int p = i; for(int j = 0; j <= n; ++j){ if(i + p > l) c[i]++ , p = i; if(a[p] == a[j])p++; else p = i; } } for(int i = 1;i <= n - l + 1; ++i)cout << c[i] << " "; return 0; } for(int i = 1; i <= n - l+1; ++i){ for(int j = i + 1; j <= n - l+1; ++j){ int cnt = 0; for(int k = 0; k < l; ++k){ if(a[i + k] != a[j + k]) cnt++; } B[i].emplace_back(cnt); B[j].emplace_back(cnt); } } for(int i = 1; i <= n - l+1; ++i) sort(B[i].begin() , B[i].end()); /* for(int i = 1; i <= n -l+1; ++i){ for(int x : B[i])cout << x << " ";cout << endl; } */ for(int i = 0; i < q; ++i){ for(int j = 1; j <= n-l+1; ++j) cout << upper_bound(B[j].begin() , B[j].end() , Q[i]) - B[j].begin() << ' '; cout << endl; } return 0; }
#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...