Submission #86092

#TimeUsernameProblemLanguageResultExecution timeMemory
86092zubecLottery (CEOI18_lot)C++14
35 / 100
663 ms6448 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int n, l, a[20010], dp[110][10010], pos[10010], b[110]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin >> n >> l; for (int i = 1; i <= n; i++){ cin >> a[i]; a[i+n] = a[i]; } int q; cin >> q; for (int i = 1; i <= q; i++){ cin >> b[i]; pos[b[i]] = i; } pos[n+1] = q+1; for (int i = n; i >= 0; i--){ if (pos[i] == 0) pos[i] = pos[i+1]; } for (int sz = 1; sz <= n; sz++){ int curans = 0; if (l+sz > n) break; for (int i = 1; i < l; i++){ if (a[i] != a[i+sz]) ++curans; } for (int i = 1; i <= n; i++){ if (i+l-1+sz > n) break; if (i != 1 && a[i-1] != a[i+sz-1]) --curans; if (a[i+l-1] != a[i+l-1+sz]) ++curans; //cout << sz << ' ' << i << ' ' << curans << endl; ++dp[pos[curans]][i]; ++dp[pos[curans]][i+sz]; } /*curans = 0; for (int i = n-l+1; i <= n; i++){ if (a[i-sz] != a[i]) ++curans; } ++dp[pos[curans]][n-l+1]; ++dp[pos[curans]][n-l+1-sz]; for (int i = n-1; i >= 1; i--){ if (i-l+1-sz <= 0) break; if (a[i+1] != a[i-sz+1]) --curans; if (a[i-l+1-sz] != a[i-l+1]) ++curans; ++dp[pos[curans]][i-l+1]; ++dp[pos[curans]][i-l+1-sz]; }*/ } for (int i = 1; i <= 100; i++){ for (int j = 1; j <= n; j++) dp[i][j] += dp[i-1][j]; } for (int i = 1; i <= q; i++){ for (int j = 1; j <= n-l+1; j++){ cout << dp[pos[b[i]]][j] << ' '; } cout << "\n"; } } /** 100 30 14 12 8 11 3 12 9 1 9 8 1 3 6 11 13 5 3 1 7 7 15 3 2 11 14 8 6 7 8 13 5 16 4 2 13 16 10 10 5 11 7 6 16 3 9 5 9 5 7 15 9 8 11 11 7 16 2 14 4 15 5 16 10 10 5 12 9 2 4 6 1 12 11 11 4 12 4 3 7 10 11 13 2 2 5 5 4 12 3 14 4 7 15 10 15 5 9 1 13 10 20 10 7 1 28 24 26 25 9 13 14 22 29 20 19 5 12 6 0 4 21 */
#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...