# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
884823 |
2023-12-08T13:44:11 Z |
Nursik |
Lottery (CEOI18_lot) |
C++14 |
|
679 ms |
8784 KB |
#include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <random>
#include <chrono>
#include <queue>
#include <functional>
#include <iostream>
#include <queue>
//#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ld long double
const ll maxn = 1e4 + 1, maxm = 2e3 + 1;
const ll mod = 1e9 + 7, mod2 = 998244353, inf = 1e9, block = 550, hb = 1000012337, base = 37, sq = 500;
const ld eps = 1e-3;
int n, l, q, k;
int a[maxn];
unsigned short dp[maxn], pdp[maxn], ans[maxn], is[maxn];
short go[maxn + 1];
unsigned short answ[maxn][105], answw[maxn][105];
vector<unsigned short> kek[maxn];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
// assert(0);
cin >> n >> l;
for (int i = 0; i <= l; ++i){
go[i] = -1;
}
for (int i = 1; i <= n; ++i){
cin >> a[i];
}
cin >> q;
vector<pair<unsigned short, short>> query;
for (int i = 1; i <= q; ++i){
cin >> k;
query.pb(mp(k, i));
}
sort(query.begin(), query.end());
for (auto it : query){
is[it.f] = it.s;
}
for (int i = l; i >= 0; --i){
if (is[i]){
go[i] = is[i];
}
else{
if (i + 1 <= l){
go[i] = go[i + 1];
}
}
}
// cout << l << '\n';
// for (int i = 0; i <= l; ++i){
// assert(go[i] <= l);
//}
for (int i = n; i >= 1; --i){
for (int j = n; j >= 1; --j){
dp[j] = pdp[j + 1];
if (i + l <= n && j + l <= n){
dp[j] -= (a[i + l] != a[j + l]);
}
dp[j] += (a[i] != a[j]);
if (j + l - 1 <= n && i + l - 1 <= n && i != j){
if (go[dp[j]] != -1){
// assert(go[dp[j]] <= 100);
// assert(i <= n);
answ[i][go[dp[j]]] += 1;
}
}
}
for (int j = n; j >= 1; --j){
pdp[j] = dp[j];
}
}
for (int i = 0; i < q; ++i){
if (i > 0 && query[i].f == query[i - 1].f){
for (int j = 1; j <= n; ++j){
answw[j][query[i].s] = answw[j][query[i - 1].s];
}
continue;
}
for (int j = 1; j <= n; ++j){
if (go[query[i].f] != -1){
// assert(go[query[i].f] <= l);
// assert(query[i].s <= q);
answw[j][query[i].s] += answ[j][go[query[i].f]];
}
if (i > 0){
answw[j][query[i].s] += answw[j][query[i - 1].s];
}
}
}
for (int i = 1; i <= q; ++i){
for (int j = 1; j <= n - l + 1; ++j){
cout << answw[j][i] << " ";
}
cout << '\n';
}
}
/*
a.cpp:103:21: runtime error: index 101 out of bounds for type 'unsigned short[101]'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior a.cpp:103:21 in
a.cpp:120:37: runtime error: index 101 out of bounds for type 'unsigned short[101]'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior a.cpp:120:37 in
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
2 ms |
4744 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
2 ms |
4700 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
2 ms |
4700 KB |
Output is correct |
11 |
Correct |
2 ms |
4696 KB |
Output is correct |
12 |
Correct |
2 ms |
4700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
2 ms |
4744 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
2 ms |
4700 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
2 ms |
4700 KB |
Output is correct |
11 |
Correct |
2 ms |
4696 KB |
Output is correct |
12 |
Correct |
2 ms |
4700 KB |
Output is correct |
13 |
Correct |
14 ms |
4956 KB |
Output is correct |
14 |
Correct |
12 ms |
4700 KB |
Output is correct |
15 |
Correct |
9 ms |
4700 KB |
Output is correct |
16 |
Correct |
11 ms |
4808 KB |
Output is correct |
17 |
Correct |
10 ms |
4700 KB |
Output is correct |
18 |
Correct |
10 ms |
4800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
368 ms |
4700 KB |
Output is correct |
2 |
Correct |
238 ms |
4952 KB |
Output is correct |
3 |
Correct |
205 ms |
4892 KB |
Output is correct |
4 |
Correct |
207 ms |
4956 KB |
Output is correct |
5 |
Correct |
160 ms |
4912 KB |
Output is correct |
6 |
Correct |
246 ms |
4912 KB |
Output is correct |
7 |
Correct |
191 ms |
4688 KB |
Output is correct |
8 |
Correct |
240 ms |
4944 KB |
Output is correct |
9 |
Correct |
205 ms |
4948 KB |
Output is correct |
10 |
Correct |
212 ms |
4928 KB |
Output is correct |
11 |
Correct |
16 ms |
4700 KB |
Output is correct |
12 |
Correct |
201 ms |
4904 KB |
Output is correct |
13 |
Correct |
166 ms |
4692 KB |
Output is correct |
14 |
Correct |
169 ms |
4928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
368 ms |
4700 KB |
Output is correct |
2 |
Correct |
238 ms |
4952 KB |
Output is correct |
3 |
Correct |
205 ms |
4892 KB |
Output is correct |
4 |
Correct |
207 ms |
4956 KB |
Output is correct |
5 |
Correct |
160 ms |
4912 KB |
Output is correct |
6 |
Correct |
246 ms |
4912 KB |
Output is correct |
7 |
Correct |
191 ms |
4688 KB |
Output is correct |
8 |
Correct |
240 ms |
4944 KB |
Output is correct |
9 |
Correct |
205 ms |
4948 KB |
Output is correct |
10 |
Correct |
212 ms |
4928 KB |
Output is correct |
11 |
Correct |
16 ms |
4700 KB |
Output is correct |
12 |
Correct |
201 ms |
4904 KB |
Output is correct |
13 |
Correct |
166 ms |
4692 KB |
Output is correct |
14 |
Correct |
169 ms |
4928 KB |
Output is correct |
15 |
Correct |
679 ms |
4952 KB |
Output is correct |
16 |
Correct |
198 ms |
4948 KB |
Output is correct |
17 |
Correct |
230 ms |
4964 KB |
Output is correct |
18 |
Correct |
239 ms |
4952 KB |
Output is correct |
19 |
Correct |
206 ms |
4952 KB |
Output is correct |
20 |
Correct |
204 ms |
4956 KB |
Output is correct |
21 |
Correct |
203 ms |
4968 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
4700 KB |
Output is correct |
3 |
Correct |
2 ms |
4744 KB |
Output is correct |
4 |
Correct |
1 ms |
4700 KB |
Output is correct |
5 |
Correct |
1 ms |
4700 KB |
Output is correct |
6 |
Correct |
1 ms |
4700 KB |
Output is correct |
7 |
Correct |
1 ms |
4700 KB |
Output is correct |
8 |
Correct |
2 ms |
4700 KB |
Output is correct |
9 |
Correct |
1 ms |
4700 KB |
Output is correct |
10 |
Correct |
2 ms |
4700 KB |
Output is correct |
11 |
Correct |
2 ms |
4696 KB |
Output is correct |
12 |
Correct |
2 ms |
4700 KB |
Output is correct |
13 |
Correct |
14 ms |
4956 KB |
Output is correct |
14 |
Correct |
12 ms |
4700 KB |
Output is correct |
15 |
Correct |
9 ms |
4700 KB |
Output is correct |
16 |
Correct |
11 ms |
4808 KB |
Output is correct |
17 |
Correct |
10 ms |
4700 KB |
Output is correct |
18 |
Correct |
10 ms |
4800 KB |
Output is correct |
19 |
Correct |
368 ms |
4700 KB |
Output is correct |
20 |
Correct |
238 ms |
4952 KB |
Output is correct |
21 |
Correct |
205 ms |
4892 KB |
Output is correct |
22 |
Correct |
207 ms |
4956 KB |
Output is correct |
23 |
Correct |
160 ms |
4912 KB |
Output is correct |
24 |
Correct |
246 ms |
4912 KB |
Output is correct |
25 |
Correct |
191 ms |
4688 KB |
Output is correct |
26 |
Correct |
240 ms |
4944 KB |
Output is correct |
27 |
Correct |
205 ms |
4948 KB |
Output is correct |
28 |
Correct |
212 ms |
4928 KB |
Output is correct |
29 |
Correct |
16 ms |
4700 KB |
Output is correct |
30 |
Correct |
201 ms |
4904 KB |
Output is correct |
31 |
Correct |
166 ms |
4692 KB |
Output is correct |
32 |
Correct |
169 ms |
4928 KB |
Output is correct |
33 |
Correct |
679 ms |
4952 KB |
Output is correct |
34 |
Correct |
198 ms |
4948 KB |
Output is correct |
35 |
Correct |
230 ms |
4964 KB |
Output is correct |
36 |
Correct |
239 ms |
4952 KB |
Output is correct |
37 |
Correct |
206 ms |
4952 KB |
Output is correct |
38 |
Correct |
204 ms |
4956 KB |
Output is correct |
39 |
Correct |
203 ms |
4968 KB |
Output is correct |
40 |
Correct |
304 ms |
5460 KB |
Output is correct |
41 |
Correct |
193 ms |
4920 KB |
Output is correct |
42 |
Correct |
236 ms |
5648 KB |
Output is correct |
43 |
Correct |
233 ms |
5168 KB |
Output is correct |
44 |
Correct |
257 ms |
5424 KB |
Output is correct |
45 |
Correct |
339 ms |
8528 KB |
Output is correct |
46 |
Correct |
162 ms |
5188 KB |
Output is correct |
47 |
Correct |
369 ms |
8784 KB |
Output is correct |
48 |
Correct |
247 ms |
6996 KB |
Output is correct |
49 |
Correct |
254 ms |
7476 KB |
Output is correct |