# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121074 | 2019-06-26T04:47:00 Z | BThero | Lottery (CEOI18_lot) | C++17 | 759 ms | 8256 KB |
// Why am I so dumb? :c // chrono::system_clock::now().time_since_epoch().count() //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define fi first #define se second using namespace std; using namespace __gnu_pbds; typedef long long ll; template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const int MAXN = (int)1e4 + 5; int diff[MAXN], arr[MAXN]; int ans[105][MAXN]; int cid[MAXN]; int req[105]; int n, l, q; void compress() { vector<int> V; for (int i = 1; i <= q; ++i) { V.pb(req[i]); } sort(all(V)); V.resize(unique(all(V)) - V.begin()); for (int i = 0; i <= n; ++i) { cid[i] = lower_bound(all(V), i) - V.begin(); } for (int i = 1; i <= q; ++i) { req[i] = cid[req[i]]; } } void solve() { scanf("%d %d", &n, &l); for (int i = 1; i <= n; ++i) { scanf("%d", &arr[i]); } scanf("%d", &q); for (int i = 1; i <= q; ++i) { scanf("%d", &req[i]); } compress(); for (int d = 1; d <= n; ++d) { for (int i = 1; i <= n; ++i) { diff[i] = 0; } for (int i = 1; i + d <= n; ++i) { if (arr[i] != arr[i + d]) { ++diff[i]; if (i > l) { --diff[i - l]; } } } for (int i = n - 1; i > 0; --i) { diff[i] += diff[i + 1]; } for (int i = 1; i + d <= n - l + 1; ++i) { ++ans[cid[diff[i]]][i]; ++ans[cid[diff[i]]][i + d]; } } for (int i = 1; i < q; ++i) { for (int j = 1; j <= n - l + 1; ++j) { ans[i][j] += ans[i - 1][j]; } } for (int i = 1; i <= q; ++i) { for (int j = 1; j <= n - l + 1; ++j) { printf("%d ", ans[req[i]][j]); } printf("\n"); } } int main() { int tt = 1; while (tt--) { solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
13 | Correct | 23 ms | 504 KB | Output is correct |
14 | Correct | 19 ms | 576 KB | Output is correct |
15 | Correct | 18 ms | 512 KB | Output is correct |
16 | Correct | 21 ms | 640 KB | Output is correct |
17 | Correct | 20 ms | 768 KB | Output is correct |
18 | Correct | 20 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 620 ms | 632 KB | Output is correct |
2 | Correct | 623 ms | 556 KB | Output is correct |
3 | Correct | 480 ms | 512 KB | Output is correct |
4 | Correct | 433 ms | 596 KB | Output is correct |
5 | Correct | 336 ms | 640 KB | Output is correct |
6 | Correct | 425 ms | 680 KB | Output is correct |
7 | Correct | 319 ms | 632 KB | Output is correct |
8 | Correct | 338 ms | 632 KB | Output is correct |
9 | Correct | 443 ms | 760 KB | Output is correct |
10 | Correct | 433 ms | 640 KB | Output is correct |
11 | Correct | 39 ms | 384 KB | Output is correct |
12 | Correct | 320 ms | 732 KB | Output is correct |
13 | Correct | 395 ms | 632 KB | Output is correct |
14 | Correct | 369 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 620 ms | 632 KB | Output is correct |
2 | Correct | 623 ms | 556 KB | Output is correct |
3 | Correct | 480 ms | 512 KB | Output is correct |
4 | Correct | 433 ms | 596 KB | Output is correct |
5 | Correct | 336 ms | 640 KB | Output is correct |
6 | Correct | 425 ms | 680 KB | Output is correct |
7 | Correct | 319 ms | 632 KB | Output is correct |
8 | Correct | 338 ms | 632 KB | Output is correct |
9 | Correct | 443 ms | 760 KB | Output is correct |
10 | Correct | 433 ms | 640 KB | Output is correct |
11 | Correct | 39 ms | 384 KB | Output is correct |
12 | Correct | 320 ms | 732 KB | Output is correct |
13 | Correct | 395 ms | 632 KB | Output is correct |
14 | Correct | 369 ms | 760 KB | Output is correct |
15 | Correct | 577 ms | 632 KB | Output is correct |
16 | Correct | 418 ms | 760 KB | Output is correct |
17 | Correct | 601 ms | 792 KB | Output is correct |
18 | Correct | 435 ms | 768 KB | Output is correct |
19 | Correct | 432 ms | 760 KB | Output is correct |
20 | Correct | 430 ms | 760 KB | Output is correct |
21 | Correct | 434 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 512 KB | Output is correct |
10 | Correct | 3 ms | 512 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 512 KB | Output is correct |
13 | Correct | 23 ms | 504 KB | Output is correct |
14 | Correct | 19 ms | 576 KB | Output is correct |
15 | Correct | 18 ms | 512 KB | Output is correct |
16 | Correct | 21 ms | 640 KB | Output is correct |
17 | Correct | 20 ms | 768 KB | Output is correct |
18 | Correct | 20 ms | 640 KB | Output is correct |
19 | Correct | 620 ms | 632 KB | Output is correct |
20 | Correct | 623 ms | 556 KB | Output is correct |
21 | Correct | 480 ms | 512 KB | Output is correct |
22 | Correct | 433 ms | 596 KB | Output is correct |
23 | Correct | 336 ms | 640 KB | Output is correct |
24 | Correct | 425 ms | 680 KB | Output is correct |
25 | Correct | 319 ms | 632 KB | Output is correct |
26 | Correct | 338 ms | 632 KB | Output is correct |
27 | Correct | 443 ms | 760 KB | Output is correct |
28 | Correct | 433 ms | 640 KB | Output is correct |
29 | Correct | 39 ms | 384 KB | Output is correct |
30 | Correct | 320 ms | 732 KB | Output is correct |
31 | Correct | 395 ms | 632 KB | Output is correct |
32 | Correct | 369 ms | 760 KB | Output is correct |
33 | Correct | 577 ms | 632 KB | Output is correct |
34 | Correct | 418 ms | 760 KB | Output is correct |
35 | Correct | 601 ms | 792 KB | Output is correct |
36 | Correct | 435 ms | 768 KB | Output is correct |
37 | Correct | 432 ms | 760 KB | Output is correct |
38 | Correct | 430 ms | 760 KB | Output is correct |
39 | Correct | 434 ms | 760 KB | Output is correct |
40 | Correct | 661 ms | 2140 KB | Output is correct |
41 | Correct | 314 ms | 888 KB | Output is correct |
42 | Correct | 447 ms | 2168 KB | Output is correct |
43 | Correct | 447 ms | 1912 KB | Output is correct |
44 | Correct | 444 ms | 1784 KB | Output is correct |
45 | Correct | 759 ms | 8068 KB | Output is correct |
46 | Correct | 322 ms | 1656 KB | Output is correct |
47 | Correct | 510 ms | 8256 KB | Output is correct |
48 | Correct | 505 ms | 6492 KB | Output is correct |
49 | Correct | 532 ms | 7104 KB | Output is correct |