Submission #807021

#TimeUsernameProblemLanguageResultExecution timeMemory
807021Valaki2Lottery (CEOI18_lot)C++14
0 / 100
324 ms4404 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 10000; //!!!!! const int maxq = 100; int n, l, q; int v[1 + maxn]; int conv[1 + maxn]; int dp[1 + maxn]; int ans[1 + maxn][1 + maxq]; int qry[1 + maxq]; void solve() { cin >> n >> l; for(int i = 1; i <= n; i++) { cin >> v[i]; } cin >> q; for(int i = 1; i <= q; i++) { cin >> qry[i]; conv[qry[i]] = qry[i]; } for(int i = n - 1; i >= 0; i--) { if(conv[i] == 0) { conv[i] = conv[i + 1]; } } for(int offset = 1; offset <= n - l; offset++) { for(int i = 1; i <= offset; i++) { dp[i] = 0; } for(int i = 1 + offset; i <= n; i++) { dp[i] = dp[i - 1]; if(v[i] != v[i - offset]) { dp[i]++; } if(i - l + 1 - offset >= 1) { #define a (i - l + 1) #define b (i - l + 1 - offset) #define dist (dp[i] - dp[i - l]) ans[a][conv[dist]]++; ans[b][conv[dist]]++; } } } for(int i = 1; i <= n - l + 1; i++) { for(int j = 1; j < q; j++) { ans[i][j + 1] += ans[i][j]; } } for(int i = 1; i <= q; i++) { for(int j = 1; j <= n - l + 1; j++) { cout << ans[j][i] << " "; } cout << "\n"; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); 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...