Submission #161370

#TimeUsernameProblemLanguageResultExecution timeMemory
161370rama_pangLottery (CEOI18_lot)C++14
80 / 100
3051 ms3456 KiB
#include <bits/stdc++.h> using namespace std; int N, L, q, Q[100], A[10005]; int ans[100][10005]; 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]; /* The segment compared is segment i...(i + L - 1) and (i + shift)...(i + L + shift - 1) */ for (int shift = 1; shift + L - 1 < N; shift++) { int 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 for (int j = 0; j < q; j++) if (Q[j] >= L - similiar) ans[j][i]++, ans[j][i + shift]++; if (A[i] == A[i + shift]) similiar--; if (A[i + L] == A[i + shift + L]) similiar++; } } 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...