# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
723556 |
2023-04-14T05:05:21 Z |
penguin133 |
Lottery (CEOI18_lot) |
C++17 |
|
727 ms |
65536 KB |
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vector < vector <int> > pref;
vector <int> ft;
int n, k, q;
vector < vector <int> > mp;
int A[10005];
void solve(){
cin >> n >> k;
ft.resize(n+1);
pref.resize(n-k+2);
for(int i=0;i<n-k+2;i++)pref[i].resize(k+1);
for(int i=1;i<=n;i++){
cin >> A[i];
}
for(int i=1;i<=n;i++){
for(auto &j : ft)j = 0;
for(int j=1;j<=n-i;j++){
if(A[j] != A[i+j])continue;
int a = j, b = i + j;
int lb = 1 + max(0, b - (n - k + 1));
int ub = min(a, k);
//cerr << i << ' ' << j[a] << ' ' << j[b] << ' ' << j[b] - j[a] << ' ' << lb << ' ' << ub << ' ' << ft[j[b]-j[a]].size() << '\n';
if(lb > ub)continue;
ft[a-ub+1]++;
ft[a-lb+2]--;
}
for(int j=1;j<=n-k-i+1;j++){
ft[j] += ft[j-1];
//cout << ft[j] << ' ';
pref[j][k-ft[j]]++;
pref[j+i][k-ft[j]]++;
}
//cout << '\n';
}
for(int i=1;i<n-k+2;i++){
for(int j=1;j<=k;j++)pref[i][j] += pref[i][j-1];
//for(int j=0;j<=k;j++)cerr << pref[i][j] << ' ';
//cerr << '\n';
}
cin >> q;
while(q--){
int x; cin >> x;
for(int i=1;i<=n-k+1;i++)cout << pref[i][x] << ' ';
cout << '\n';
}
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int tc = 1;
//cin >> tc;
for(int tc1=1;tc1<=tc;tc1++){
// cout << "Case #" << tc1 << ": ";
solve();
}
}
Compilation message
lot.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
62 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
20 ms |
452 KB |
Output is correct |
14 |
Correct |
15 ms |
3892 KB |
Output is correct |
15 |
Correct |
14 ms |
3892 KB |
Output is correct |
16 |
Correct |
21 ms |
2108 KB |
Output is correct |
17 |
Correct |
19 ms |
2572 KB |
Output is correct |
18 |
Correct |
18 ms |
2596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
724 ms |
960 KB |
Output is correct |
2 |
Correct |
727 ms |
1120 KB |
Output is correct |
3 |
Correct |
474 ms |
976 KB |
Output is correct |
4 |
Correct |
484 ms |
8560 KB |
Output is correct |
5 |
Runtime error |
29 ms |
65536 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
724 ms |
960 KB |
Output is correct |
2 |
Correct |
727 ms |
1120 KB |
Output is correct |
3 |
Correct |
474 ms |
976 KB |
Output is correct |
4 |
Correct |
484 ms |
8560 KB |
Output is correct |
5 |
Runtime error |
29 ms |
65536 KB |
Execution killed with signal 9 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
20 ms |
452 KB |
Output is correct |
14 |
Correct |
15 ms |
3892 KB |
Output is correct |
15 |
Correct |
14 ms |
3892 KB |
Output is correct |
16 |
Correct |
21 ms |
2108 KB |
Output is correct |
17 |
Correct |
19 ms |
2572 KB |
Output is correct |
18 |
Correct |
18 ms |
2596 KB |
Output is correct |
19 |
Correct |
724 ms |
960 KB |
Output is correct |
20 |
Correct |
727 ms |
1120 KB |
Output is correct |
21 |
Correct |
474 ms |
976 KB |
Output is correct |
22 |
Correct |
484 ms |
8560 KB |
Output is correct |
23 |
Runtime error |
29 ms |
65536 KB |
Execution killed with signal 9 |
24 |
Halted |
0 ms |
0 KB |
- |