# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
807510 | 2023-08-04T18:30:23 Z | Valaki2 | Lottery (CEOI18_lot) | C++14 | 446 ms | 8256 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second const int maxn = 10000; //!!!!! const int maxq = 100; int n, l, q; int v[1 + maxn]; int conv[1 + maxn]; int dp[1 + maxn]; int ans[1 + maxn][1 + maxq]; int qry[1 + maxq]; void solve() { cin >> n >> l; for(int i = 1; i <= n; i++) { cin >> v[i]; } cin >> q; for(int i = n; i >= 0; i--) { conv[i] = q + 1; } for(int i = 1; i <= q; i++) { cin >> qry[i]; conv[qry[i]] = i; } vector<pii> sorted; for(int i = n; i >= 0; i--) { if(conv[i] != q + 1) { sorted.pb(mp(i, conv[i])); } } sort(sorted.begin(), sorted.end()); for(int i = n - 1; i >= 0; i--) { if(conv[i] == q + 1) { conv[i] = conv[i + 1]; } } for(int offset = 1; offset <= n - l; offset++) { for(int i = 1; i <= offset; i++) { dp[i] = 0; } for(int i = 1 + offset; i <= n; i++) { dp[i] = dp[i - 1]; if(v[i] != v[i - offset]) { dp[i]++; } if(i - l + 1 - offset >= 1) { #define a (i - l + 1) #define b (i - l + 1 - offset) #define dist (dp[i] - dp[i - l]) ans[a][conv[dist]]++; ans[b][conv[dist]]++; } } } for(int i = 1; i <= n - l + 1; i++) { for(int j = 1; j < sorted.size(); j++) { if(sorted[j].fi != sorted[j - 1].fi) { ans[i][sorted[j].se] += ans[i][sorted[j - 1].se]; } } } for(int i = 1; i <= q; i++) { for(int j = 1; j <= n - l + 1; j++) { cout << ans[j][conv[qry[i]]] << " "; } cout << "\n"; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 324 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 468 KB | Output is correct |
12 | Correct | 4 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 324 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 468 KB | Output is correct |
12 | Correct | 4 ms | 340 KB | Output is correct |
13 | Correct | 9 ms | 1100 KB | Output is correct |
14 | Correct | 10 ms | 928 KB | Output is correct |
15 | Correct | 8 ms | 908 KB | Output is correct |
16 | Correct | 9 ms | 1092 KB | Output is correct |
17 | Correct | 12 ms | 1092 KB | Output is correct |
18 | Correct | 9 ms | 1104 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 363 ms | 4392 KB | Output is correct |
2 | Correct | 336 ms | 4428 KB | Output is correct |
3 | Correct | 238 ms | 4396 KB | Output is correct |
4 | Correct | 211 ms | 4400 KB | Output is correct |
5 | Correct | 124 ms | 2524 KB | Output is correct |
6 | Correct | 205 ms | 4196 KB | Output is correct |
7 | Correct | 105 ms | 2516 KB | Output is correct |
8 | Correct | 149 ms | 3292 KB | Output is correct |
9 | Correct | 216 ms | 4344 KB | Output is correct |
10 | Correct | 231 ms | 4408 KB | Output is correct |
11 | Correct | 15 ms | 1172 KB | Output is correct |
12 | Correct | 141 ms | 3264 KB | Output is correct |
13 | Correct | 160 ms | 2860 KB | Output is correct |
14 | Correct | 134 ms | 2860 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 363 ms | 4392 KB | Output is correct |
2 | Correct | 336 ms | 4428 KB | Output is correct |
3 | Correct | 238 ms | 4396 KB | Output is correct |
4 | Correct | 211 ms | 4400 KB | Output is correct |
5 | Correct | 124 ms | 2524 KB | Output is correct |
6 | Correct | 205 ms | 4196 KB | Output is correct |
7 | Correct | 105 ms | 2516 KB | Output is correct |
8 | Correct | 149 ms | 3292 KB | Output is correct |
9 | Correct | 216 ms | 4344 KB | Output is correct |
10 | Correct | 231 ms | 4408 KB | Output is correct |
11 | Correct | 15 ms | 1172 KB | Output is correct |
12 | Correct | 141 ms | 3264 KB | Output is correct |
13 | Correct | 160 ms | 2860 KB | Output is correct |
14 | Correct | 134 ms | 2860 KB | Output is correct |
15 | Correct | 247 ms | 4268 KB | Output is correct |
16 | Correct | 196 ms | 4084 KB | Output is correct |
17 | Correct | 227 ms | 4468 KB | Output is correct |
18 | Correct | 225 ms | 4432 KB | Output is correct |
19 | Correct | 215 ms | 4440 KB | Output is correct |
20 | Correct | 205 ms | 4436 KB | Output is correct |
21 | Correct | 220 ms | 4440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 324 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 1 ms | 468 KB | Output is correct |
12 | Correct | 4 ms | 340 KB | Output is correct |
13 | Correct | 9 ms | 1100 KB | Output is correct |
14 | Correct | 10 ms | 928 KB | Output is correct |
15 | Correct | 8 ms | 908 KB | Output is correct |
16 | Correct | 9 ms | 1092 KB | Output is correct |
17 | Correct | 12 ms | 1092 KB | Output is correct |
18 | Correct | 9 ms | 1104 KB | Output is correct |
19 | Correct | 363 ms | 4392 KB | Output is correct |
20 | Correct | 336 ms | 4428 KB | Output is correct |
21 | Correct | 238 ms | 4396 KB | Output is correct |
22 | Correct | 211 ms | 4400 KB | Output is correct |
23 | Correct | 124 ms | 2524 KB | Output is correct |
24 | Correct | 205 ms | 4196 KB | Output is correct |
25 | Correct | 105 ms | 2516 KB | Output is correct |
26 | Correct | 149 ms | 3292 KB | Output is correct |
27 | Correct | 216 ms | 4344 KB | Output is correct |
28 | Correct | 231 ms | 4408 KB | Output is correct |
29 | Correct | 15 ms | 1172 KB | Output is correct |
30 | Correct | 141 ms | 3264 KB | Output is correct |
31 | Correct | 160 ms | 2860 KB | Output is correct |
32 | Correct | 134 ms | 2860 KB | Output is correct |
33 | Correct | 247 ms | 4268 KB | Output is correct |
34 | Correct | 196 ms | 4084 KB | Output is correct |
35 | Correct | 227 ms | 4468 KB | Output is correct |
36 | Correct | 225 ms | 4432 KB | Output is correct |
37 | Correct | 215 ms | 4440 KB | Output is correct |
38 | Correct | 205 ms | 4436 KB | Output is correct |
39 | Correct | 220 ms | 4440 KB | Output is correct |
40 | Correct | 357 ms | 5124 KB | Output is correct |
41 | Correct | 27 ms | 928 KB | Output is correct |
42 | Correct | 226 ms | 5132 KB | Output is correct |
43 | Correct | 233 ms | 4688 KB | Output is correct |
44 | Correct | 239 ms | 4816 KB | Output is correct |
45 | Correct | 446 ms | 8164 KB | Output is correct |
46 | Correct | 32 ms | 1164 KB | Output is correct |
47 | Correct | 293 ms | 8256 KB | Output is correct |
48 | Correct | 267 ms | 6348 KB | Output is correct |
49 | Correct | 253 ms | 7000 KB | Output is correct |