제출 #571908

#제출 시각아이디문제언어결과실행 시간메모리
571908piOOELottery (CEOI18_lot)C++17
80 / 100
105 ms16000 KiB
#include <bits/stdc++.h> using namespace std; #define sz(x) ((int)size(x)) #define all(x) begin(x), end(x) #define trace(x) cout << #x << ": " << (x) << endl; typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; } const int N = 10000, N2 = 2000; const ll infL = 3e18; int a[N], g[N2][N2], n, l, answer[N]; int count(int i, int j) { if (i == j) return 0; int ans = 0; for (int id = 0; id < l; ++id) { ans += (a[i + id] != a[j + id]); } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> l; for (int i = 0; i < n; ++i) { cin >> a[i]; } if (n <= 2000) { for (int i = n - l - 1; i > -1; --i) { g[i][n - l] = g[n - l][i] = count(i, n - l); for (int j = 1; j <= i; ++j) { g[i - j][n - l - j] = g[n - l - j][i - j] = g[i - j + 1][n - l - j + 1] + (a[i - j] != a[n - l - j]) - (a[i - j + l] != a[n - j]); } } int q; cin >> q; while (q--) { int k; cin >> k; for (int i = 0; i <= n - l; ++i) { int ans = 0; for (int j = 0; j <= n - l; ++j) { if (i != j && g[i][j] <= k) ++ans; } cout << ans << " "; } cout << '\n'; } } else { int q; cin >> q; assert(q == 1); int k; cin >> k; for (int i = n - l - 1; i > -1; --i) { int ct = count(i, n - l); answer[i] += (ct <= k); answer[n - l] += (ct <= k); for (int j = 1; j <= i; ++j) { ct = ct + (a[i - j] != a[n - l - j]) - (a[i - j + l] != a[n - j]); answer[i - j] += (ct <= k); answer[n - l - j] += (ct <= k); } } for (int i = 0; i <= n - l; ++i) { cout << answer[i] << " "; } 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...