#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
#define taskname "Lottery"
int n, l, q;
int a[10001];
int to[10001];
//int ans[10001][101];
int ans[10001];
int r[101];
pair <int, int> k[101];
int main(){
#ifdef Aria
if(fopen(taskname".in", "r"))
freopen(taskname".in", "r", stdin);
#endif // Aria
read(n);
read(l);
FOR(i, 1, n) read(a[i]);
read(q);
FOR(i, 1, q){
read(k[i].first);
k[i].second=i;
}
sort(k+1, k+q+1);
DFOR(i, q, 1){
r[k[i].second]=i;
FOR(j, 0, k[i].first) to[j]=i;
}
FOR(d, 1, n){
if(d+l>n) break;
int sum=0;
FFOR(i, 1, l) sum+=(a[i]!=a[i+d]);
FOR(i, l, n){
if(i+d>n) break;
sum+=(a[i]!=a[i+d]);
// int sum=0;
// FFOR(j, 0, l) sum+=a[i-j]!=a[i+d-j];
// ans[i][to[sum]]++;
// ans[i+d][to[sum]]++;
if(sum==0) ans[i]++;
if(sum==0) ans[i+d]++;
sum-=(a[i-l+1]!=a[i-l+1+d]);
}
}
// FOR(i, 1, n) FOR(j, 1, q) ans[i][j]+=ans[i][j-1];
// sort(k+1, k+q+1, [](pair <int, int> A, pair <int, int> B){
// return A.second<B.second;
// });
// FOR(i, 1, q) FOR(j, l, n) write(ans[j][r[k[i].second]]), putchar(" \n"[j==n]);
FOR(i, l, n) write(ans[i]), putchar(" \n"[i==n]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
143 ms |
476 KB |
Output is correct |
2 |
Correct |
87 ms |
504 KB |
Output is correct |
3 |
Correct |
80 ms |
476 KB |
Output is correct |
4 |
Correct |
81 ms |
384 KB |
Output is correct |
5 |
Correct |
41 ms |
504 KB |
Output is correct |
6 |
Correct |
77 ms |
640 KB |
Output is correct |
7 |
Correct |
47 ms |
512 KB |
Output is correct |
8 |
Correct |
70 ms |
512 KB |
Output is correct |
9 |
Correct |
82 ms |
512 KB |
Output is correct |
10 |
Correct |
81 ms |
512 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
53 ms |
640 KB |
Output is correct |
13 |
Correct |
49 ms |
512 KB |
Output is correct |
14 |
Correct |
49 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
143 ms |
476 KB |
Output is correct |
2 |
Correct |
87 ms |
504 KB |
Output is correct |
3 |
Correct |
80 ms |
476 KB |
Output is correct |
4 |
Correct |
81 ms |
384 KB |
Output is correct |
5 |
Correct |
41 ms |
504 KB |
Output is correct |
6 |
Correct |
77 ms |
640 KB |
Output is correct |
7 |
Correct |
47 ms |
512 KB |
Output is correct |
8 |
Correct |
70 ms |
512 KB |
Output is correct |
9 |
Correct |
82 ms |
512 KB |
Output is correct |
10 |
Correct |
81 ms |
512 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
53 ms |
640 KB |
Output is correct |
13 |
Correct |
49 ms |
512 KB |
Output is correct |
14 |
Correct |
49 ms |
512 KB |
Output is correct |
15 |
Incorrect |
80 ms |
440 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |