# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1127107 | TrieTr | Lottery (CEOI18_lot) | C++20 | 318 ms | 8508 KiB |
#include<bits/stdc++.h>
using namespace std;
void local() {
#define taskname ""
if (fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
}
#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;}
template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;}
const int N = 1e4 + 5;
const int Q = 1e2 + 5;
int n, l, q, a[N], que[N];
int cnt[N << 1], pf[N], diff[N];
int ans[N][Q];
void update(int id, int v) {
for(int i = 1; i <= n; i++) cnt[i - id + N] += (a[i] != a[id]) * v;
}
int main() {
fastio; local();
cin >> n >> l; int lim = n - l + 1;
for(int i = 1; i <= n; i++) cin >> a[i];
cin >> q;
for(int i = 1; i <= q; i++) cin >> que[i];
for(int i = 1, le = 1, ri = 1; i <= lim; i++) {
while(ri < i + l) update(ri++, 1);
while(le < i) update(le++, -1);
memset(pf, 0, sizeof(pf));
for(int j = 1; j <= lim; j++) pf[cnt[j - i + N]]++;
for(int j = 1; j <= l; j++) pf[j] += pf[j - 1];
for(int j = 1; j <= q; j++) ans[i][j] = pf[que[j]] - 1;
}
for(int i = 1; i <= q; i++)
for(int j = 1; j <= lim; j++) cout << ans[j][i] << " \n"[j == lim];
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |