Submission #825169

#TimeUsernameProblemLanguageResultExecution timeMemory
825169drdilyorLottery (CEOI18_lot)C++17
35 / 100
292 ms4360 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; signed main() { cin.tie(0)->sync_with_stdio(0); int n, m; cin >> n >> m; vector<int> arr(n); for (int& i : arr) cin >> i; int q; cin >> q; vector<int> ask(q); for (int& i : ask) cin >> i; vector<int> rev(n+1, -1); { int k = 0; for (int i : ask) { rev[i] = k; k++; } } for (int i = n-1; i >= 0; i--) { if (rev[i] == -1) rev[i] = rev[i+1]; if (rev[i] == -1) rev[i] = 100; } vector<array<int, 101>> cnt(n, {{}}); for (int b = 1; b + m <= n; b++) { int al = 0, ar = m-1; int diff = 0; int bl = b, br = b + m-1; for (int i = 0; i < m; i++) diff += arr[al+i] != arr[bl+i]; // cout << "[" << al << ".." << ar << "] and [" << bl << ".." << br << "] with " << diff << "\n"; cnt[al][rev[diff]]++; cnt[bl][rev[diff]]++; while (br < n-1) { diff -= arr[al++] != arr[bl++]; diff += arr[++ar] != arr[++br]; // cout << "[" << al << ".." << ar << "] and [" << bl << ".." << br << "] with " << diff << "\n"; cnt[al][rev[diff]]++; cnt[bl][rev[diff]]++; } } for (int i = 0; i < n; i++) { for (int j = 1; j <= 100; j++) cnt[i][j] += cnt[i][j-1]; } for (int k : ask) { for (int i = 0; i + m <= n; i++) { cout << cnt[i][rev[k]] << ' '; } cout << '\n'; } return 0; }
#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...