Submission #161373

#TimeUsernameProblemLanguageResultExecution timeMemory
161373rama_pangLottery (CEOI18_lot)C++14
0 / 100
779 ms460 KiB
#include <bits/stdc++.h> using namespace std; int N, L, q, A[10005]; int ans[100][10005]; pair<int, int> Q[100]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> L; for (int i = 0; i < N; i++) cin >> A[i]; cin >> q; for (int i = 0; i < q; i++) cin >> Q[i].first; for (int i = 0; i < q; i++) Q[i].second = i; sort(Q, Q + q); /* The segment compared is segment i...(i + L - 1) and (i + shift)...(i + L + shift - 1) */ for (int shift = 1, similiar = 0; shift + L - 1 < N; shift++, similiar = 0) { for (int i = 0; i < L; i++) if (A[i] == A[i + shift]) similiar++; for (int i = 0; i + shift + L - 1 < N; i++) { // then sliding window can be used int j = lower_bound(Q, Q + q, make_pair(L - similiar, -1)) - Q; ans[Q[j].second][i]++, ans[Q[j].second][i + shift]++; // Add 1 to the answer for the lowest Q possible if (A[i] == A[i + shift]) similiar--; if (A[i + L] == A[i + shift + L]) similiar++; } } /* If Q[i] <= Q[j], then all answers from Q[i] can be used in Q[j] */ for (int i = 0; i < N; i++) for (int j = 1; j < q; j++) ans[Q[j].second][i] += ans[Q[j - 1].second][i]; for (int i = 0; i < q; i++) { for (int j = 0; j < N - L + 1; j++) cout << ans[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...