Submission #1317657

#TimeUsernameProblemLanguageResultExecution timeMemory
1317657thuhienneLottery (CEOI18_lot)C++20
0 / 100
146 ms4732 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define re exit(0); #define next __next__ int n,l,q; int arr[10009]; int tv[109],tmp[109],next[109],answer[10009][109]; int main() { ios_base::sync_with_stdio(0);cin.tie(nullptr); cin >> n >> l; for (int i = 1;i <= n;i++) cin >> arr[i]; cin >> q; for (int i = 1;i <= q;i++) cin >> tv[i],tmp[i] = tv[i]; tmp[q + 1] = l; sort(tmp + 1,tmp + 2 + q); tmp[0] = -1; for (int i = 1;i <= q + 1;i++) { for (int j = tmp[i - 1] + 1;j <= tmp[i];j++) next[j] = i; } for (int i = 2;i <= n - l + 1;i++) { //sliding window but there are 2 at the same time int currdiff = 0; for (int j = 1;j <= l;j++) currdiff += (arr[i + j - 1] != arr[j]); answer[i][next[currdiff]] ++; answer[1][next[currdiff]] ++; int currtop = i,currbot = 1; while (currtop + l - 1 < n) { currtop ++,currbot ++; currdiff += -(arr[currtop - 1] != arr[currbot - 1]) + (arr[currtop + l - 1] != arr[currbot + l - 1]); answer[currtop][next[currdiff]]++; answer[currbot][next[currdiff]]++; } } for (int i = 1;i <= n;i++) for (int j = 1;j <= q + 1;j++) answer[i][j] += answer[i][j - 1]; for (int i = 1;i <= q;i++) { for (int j = 1;j <= n - l + 1;j++) cout << answer[j][next[tv[i]]] << " "; cout << '\n'; } } /* Aiming: == +++++*** +:::::-=* ------= ========== ================== --:--== ============-- ========== ==-------=--:=--==== ---==++ ===========--====-= ==--======== ==--================= =:::-=+ ==============----==== ==:-========= ===:=== ======= =::--=+ ======== ==--==== ==--========== ==-:=== ======= -:::-:= ======= ======= ==--:== ======= ==--=== ======= =-:::-= ======= ======= =-.-=== ======= ==-==== ======= *:::----* ======= ======= ==--:== ======= ==-================== +-:::::-+ ====== ======= ==-:-=== ======= ==--================ *=-:::::-= ======= ======= ==---=============== ==--============= +--::---==* ====--= ======= ===--================= ==:-=== =:-::::--=+ ====-=== ======= ==.-=================== ==--=== =::::::---+ ====---== ========= ==---== ======= ======= +-:---=====+ ==-===--============== ======= ======= ======= =-:::::::--=+ =--=-============= ======== ======= ======= =--::::::--=+ ============= ***++++++++++***** */
#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...