# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
855212 | 2023-09-30T18:49:32 Z | lovrot | Lottery (CEOI18_lot) | C++17 | 324 ms | 8784 KB |
#include <cstdio> #include <vector> #include <algorithm> #define EB emplace_back using namespace std; const int N = 1e4 + 10; const int M = 110; int n, q, A[N], B[N], l; int Q[N]; int CNT[N][M]; vector<int> S; void count(int a, int b) { if(a == b) return; int nim = -(a < b ? a : b); a += nim; b += nim; int diff = 0; for(int i = 0; a + i < n && b + i < n; ++i) { diff += A[a + i] != A[b + i]; if(a + i - l >= 0 && b + i - l >= 0) diff -= A[b + i - l] != A[a + i - l]; if(a + i - l + 1 >= 0 && b + i - l + 1 >= 0) { ++CNT[a + i - l + 1][Q[diff]]; ++CNT[b + i - l + 1][Q[diff]]; } } } int main() { scanf("%d%d", &n, &l); for(int i = 0; i < n; ++i) scanf("%d", A + i); scanf("%d", &q); for(int i = 0; i < q; ++i) { scanf("%d", B + i); S.EB(B[i]); } sort(S.begin(), S.end()); S.erase(unique(S.begin(), S.end()), S.end()); for(int i = l, j = S.size(); i >= 0; --i) { if(j && i == S[j - 1]) --j; Q[i] = j; } for(int i = n - l; i >= 0; --i) count(i, 0); for(int i = 0; i < n - l + 1; ++i) for(int j = 1; j < S.size(); ++j) CNT[i][j] += CNT[i][j - 1]; for(int i = 0; i < q; ++i) for(int j = 0; j < n - l + 1; ++j) printf("%d%c", CNT[j][Q[B[i]]], " \n"[j == n - l]); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 436 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 436 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 8 ms | 1116 KB | Output is correct |
14 | Correct | 7 ms | 996 KB | Output is correct |
15 | Correct | 6 ms | 856 KB | Output is correct |
16 | Correct | 9 ms | 1116 KB | Output is correct |
17 | Correct | 9 ms | 1368 KB | Output is correct |
18 | Correct | 10 ms | 1112 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 218 ms | 4700 KB | Output is correct |
2 | Correct | 219 ms | 4764 KB | Output is correct |
3 | Correct | 204 ms | 4696 KB | Output is correct |
4 | Correct | 198 ms | 4772 KB | Output is correct |
5 | Correct | 72 ms | 3412 KB | Output is correct |
6 | Correct | 173 ms | 4696 KB | Output is correct |
7 | Correct | 71 ms | 3664 KB | Output is correct |
8 | Correct | 117 ms | 3636 KB | Output is correct |
9 | Correct | 218 ms | 4692 KB | Output is correct |
10 | Correct | 195 ms | 4708 KB | Output is correct |
11 | Correct | 10 ms | 1116 KB | Output is correct |
12 | Correct | 106 ms | 3620 KB | Output is correct |
13 | Correct | 92 ms | 3636 KB | Output is correct |
14 | Correct | 95 ms | 3664 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 218 ms | 4700 KB | Output is correct |
2 | Correct | 219 ms | 4764 KB | Output is correct |
3 | Correct | 204 ms | 4696 KB | Output is correct |
4 | Correct | 198 ms | 4772 KB | Output is correct |
5 | Correct | 72 ms | 3412 KB | Output is correct |
6 | Correct | 173 ms | 4696 KB | Output is correct |
7 | Correct | 71 ms | 3664 KB | Output is correct |
8 | Correct | 117 ms | 3636 KB | Output is correct |
9 | Correct | 218 ms | 4692 KB | Output is correct |
10 | Correct | 195 ms | 4708 KB | Output is correct |
11 | Correct | 10 ms | 1116 KB | Output is correct |
12 | Correct | 106 ms | 3620 KB | Output is correct |
13 | Correct | 92 ms | 3636 KB | Output is correct |
14 | Correct | 95 ms | 3664 KB | Output is correct |
15 | Correct | 199 ms | 4644 KB | Output is correct |
16 | Correct | 165 ms | 4440 KB | Output is correct |
17 | Correct | 220 ms | 4844 KB | Output is correct |
18 | Correct | 190 ms | 4616 KB | Output is correct |
19 | Correct | 205 ms | 4700 KB | Output is correct |
20 | Correct | 194 ms | 4808 KB | Output is correct |
21 | Correct | 204 ms | 4804 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 436 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 8 ms | 1116 KB | Output is correct |
14 | Correct | 7 ms | 996 KB | Output is correct |
15 | Correct | 6 ms | 856 KB | Output is correct |
16 | Correct | 9 ms | 1116 KB | Output is correct |
17 | Correct | 9 ms | 1368 KB | Output is correct |
18 | Correct | 10 ms | 1112 KB | Output is correct |
19 | Correct | 218 ms | 4700 KB | Output is correct |
20 | Correct | 219 ms | 4764 KB | Output is correct |
21 | Correct | 204 ms | 4696 KB | Output is correct |
22 | Correct | 198 ms | 4772 KB | Output is correct |
23 | Correct | 72 ms | 3412 KB | Output is correct |
24 | Correct | 173 ms | 4696 KB | Output is correct |
25 | Correct | 71 ms | 3664 KB | Output is correct |
26 | Correct | 117 ms | 3636 KB | Output is correct |
27 | Correct | 218 ms | 4692 KB | Output is correct |
28 | Correct | 195 ms | 4708 KB | Output is correct |
29 | Correct | 10 ms | 1116 KB | Output is correct |
30 | Correct | 106 ms | 3620 KB | Output is correct |
31 | Correct | 92 ms | 3636 KB | Output is correct |
32 | Correct | 95 ms | 3664 KB | Output is correct |
33 | Correct | 199 ms | 4644 KB | Output is correct |
34 | Correct | 165 ms | 4440 KB | Output is correct |
35 | Correct | 220 ms | 4844 KB | Output is correct |
36 | Correct | 190 ms | 4616 KB | Output is correct |
37 | Correct | 205 ms | 4700 KB | Output is correct |
38 | Correct | 194 ms | 4808 KB | Output is correct |
39 | Correct | 204 ms | 4804 KB | Output is correct |
40 | Correct | 221 ms | 5492 KB | Output is correct |
41 | Correct | 13 ms | 860 KB | Output is correct |
42 | Correct | 216 ms | 5512 KB | Output is correct |
43 | Correct | 193 ms | 4948 KB | Output is correct |
44 | Correct | 203 ms | 5432 KB | Output is correct |
45 | Correct | 324 ms | 8568 KB | Output is correct |
46 | Correct | 19 ms | 1116 KB | Output is correct |
47 | Correct | 292 ms | 8784 KB | Output is correct |
48 | Correct | 246 ms | 6712 KB | Output is correct |
49 | Correct | 258 ms | 7220 KB | Output is correct |