Submission #86091

#TimeUsernameProblemLanguageResultExecution timeMemory
86091zubecLottery (CEOI18_lot)C++14
0 / 100
465 ms4520 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; } 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"; } }
#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...