# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
826306 |
2023-08-15T12:34:36 Z |
gagik_2007 |
Lottery (CEOI18_lot) |
C++17 |
|
247 ms |
8616 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=2007;
const ll M=10007;
const ll Q=107;
ll n,m,k;
ll a[M];
ll dp[2][M];
vector<pair<int,int>>qs;
vector<int>q;
int lb[M];
int res[M][Q];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>a[i];
}
cin>>m;
for(int i=0;i<m;i++){
int x;
cin>>x;
q.push_back(x);
qs.push_back({x,i});
}
qs.push_back({n+1,m});
sort(qs.begin(),qs.end());
int cur=0;
vector<int>revq(m+1);
for(int i=0;i<qs.size();i++){
revq[qs[i].ss]=i;
while(cur<=qs[i].ff){
lb[cur]=i;
cur++;
}
}
for(int i=1;i+k-1<n;i++){
for(int j=i;j-i<k;j++){
dp[0][i]+=(a[j-i]!=a[j]);
}
res[0][lb[dp[0][i]]]++;
res[i][lb[dp[0][i]]]++;
}
for(int i=1;i+k-1<n;i++){
for(int j=i+1;j+k-1<n;j++){
dp[1][j]=dp[0][j-1];
dp[1][j]-=(a[i-1]!=a[j-1]);
dp[1][j]+=(a[i+k-1]!=a[j+k-1]);
res[i][lb[dp[1][j]]]++;
res[j][lb[dp[1][j]]]++;
}
for(int j=0;j<=n;j++){
dp[0][j]=dp[1][j];
}
}
for(int i=0;i+k-1<n;i++){
for(int j=1;j<=m;j++){
res[i][j]+=res[i][j-1];
}
}
for(int i=0;i<m;i++){
for(int j=0;j+k-1<n;j++){
cout<<res[j][revq[i]]<<" ";
}
cout<<endl;
}
}
Compilation message
lot.cpp: In function 'int main()':
lot.cpp:47:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int i=0;i<qs.size();i++){
| ~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 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 |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 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 |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
11 ms |
1248 KB |
Output is correct |
14 |
Correct |
5 ms |
980 KB |
Output is correct |
15 |
Correct |
5 ms |
980 KB |
Output is correct |
16 |
Correct |
8 ms |
1164 KB |
Output is correct |
17 |
Correct |
7 ms |
1116 KB |
Output is correct |
18 |
Correct |
7 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
202 ms |
4788 KB |
Output is correct |
2 |
Correct |
192 ms |
4784 KB |
Output is correct |
3 |
Correct |
185 ms |
4788 KB |
Output is correct |
4 |
Correct |
187 ms |
4792 KB |
Output is correct |
5 |
Correct |
62 ms |
2760 KB |
Output is correct |
6 |
Correct |
164 ms |
4684 KB |
Output is correct |
7 |
Correct |
62 ms |
2752 KB |
Output is correct |
8 |
Correct |
101 ms |
3608 KB |
Output is correct |
9 |
Correct |
165 ms |
4724 KB |
Output is correct |
10 |
Correct |
169 ms |
4824 KB |
Output is correct |
11 |
Correct |
9 ms |
1236 KB |
Output is correct |
12 |
Correct |
105 ms |
3560 KB |
Output is correct |
13 |
Correct |
85 ms |
3136 KB |
Output is correct |
14 |
Correct |
79 ms |
3124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
202 ms |
4788 KB |
Output is correct |
2 |
Correct |
192 ms |
4784 KB |
Output is correct |
3 |
Correct |
185 ms |
4788 KB |
Output is correct |
4 |
Correct |
187 ms |
4792 KB |
Output is correct |
5 |
Correct |
62 ms |
2760 KB |
Output is correct |
6 |
Correct |
164 ms |
4684 KB |
Output is correct |
7 |
Correct |
62 ms |
2752 KB |
Output is correct |
8 |
Correct |
101 ms |
3608 KB |
Output is correct |
9 |
Correct |
165 ms |
4724 KB |
Output is correct |
10 |
Correct |
169 ms |
4824 KB |
Output is correct |
11 |
Correct |
9 ms |
1236 KB |
Output is correct |
12 |
Correct |
105 ms |
3560 KB |
Output is correct |
13 |
Correct |
85 ms |
3136 KB |
Output is correct |
14 |
Correct |
79 ms |
3124 KB |
Output is correct |
15 |
Correct |
190 ms |
4652 KB |
Output is correct |
16 |
Correct |
163 ms |
4444 KB |
Output is correct |
17 |
Correct |
195 ms |
4856 KB |
Output is correct |
18 |
Correct |
170 ms |
4820 KB |
Output is correct |
19 |
Correct |
186 ms |
4820 KB |
Output is correct |
20 |
Correct |
178 ms |
4828 KB |
Output is correct |
21 |
Correct |
187 ms |
4820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 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 |
468 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
2 ms |
468 KB |
Output is correct |
13 |
Correct |
11 ms |
1248 KB |
Output is correct |
14 |
Correct |
5 ms |
980 KB |
Output is correct |
15 |
Correct |
5 ms |
980 KB |
Output is correct |
16 |
Correct |
8 ms |
1164 KB |
Output is correct |
17 |
Correct |
7 ms |
1116 KB |
Output is correct |
18 |
Correct |
7 ms |
1108 KB |
Output is correct |
19 |
Correct |
202 ms |
4788 KB |
Output is correct |
20 |
Correct |
192 ms |
4784 KB |
Output is correct |
21 |
Correct |
185 ms |
4788 KB |
Output is correct |
22 |
Correct |
187 ms |
4792 KB |
Output is correct |
23 |
Correct |
62 ms |
2760 KB |
Output is correct |
24 |
Correct |
164 ms |
4684 KB |
Output is correct |
25 |
Correct |
62 ms |
2752 KB |
Output is correct |
26 |
Correct |
101 ms |
3608 KB |
Output is correct |
27 |
Correct |
165 ms |
4724 KB |
Output is correct |
28 |
Correct |
169 ms |
4824 KB |
Output is correct |
29 |
Correct |
9 ms |
1236 KB |
Output is correct |
30 |
Correct |
105 ms |
3560 KB |
Output is correct |
31 |
Correct |
85 ms |
3136 KB |
Output is correct |
32 |
Correct |
79 ms |
3124 KB |
Output is correct |
33 |
Correct |
190 ms |
4652 KB |
Output is correct |
34 |
Correct |
163 ms |
4444 KB |
Output is correct |
35 |
Correct |
195 ms |
4856 KB |
Output is correct |
36 |
Correct |
170 ms |
4820 KB |
Output is correct |
37 |
Correct |
186 ms |
4820 KB |
Output is correct |
38 |
Correct |
178 ms |
4828 KB |
Output is correct |
39 |
Correct |
187 ms |
4820 KB |
Output is correct |
40 |
Correct |
201 ms |
5556 KB |
Output is correct |
41 |
Correct |
14 ms |
1108 KB |
Output is correct |
42 |
Correct |
207 ms |
5512 KB |
Output is correct |
43 |
Correct |
183 ms |
5080 KB |
Output is correct |
44 |
Correct |
186 ms |
5112 KB |
Output is correct |
45 |
Correct |
247 ms |
8592 KB |
Output is correct |
46 |
Correct |
15 ms |
1324 KB |
Output is correct |
47 |
Correct |
239 ms |
8616 KB |
Output is correct |
48 |
Correct |
226 ms |
6716 KB |
Output is correct |
49 |
Correct |
230 ms |
7368 KB |
Output is correct |