# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
856702 | 2023-10-04T11:17:25 Z | ntkphong | Lottery (CEOI18_lot) | C++14 | 18 ms | 31780 KB |
#include <bits/stdc++.h> using namespace std; const int mxN = 2000 + 10; int n, l, q; int a[mxN]; int dp[mxN][mxN]; int prefix[mxN]; int answer[mxN][mxN]; int main() { #define taskname "" if(fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> n >> l; if(n > 2000) return 0; for(int i = 1; i <= n; i ++) cin >> a[i]; for(int i = 1; i <= n; i ++) { for(int j = 1; j <= n; j ++) { dp[i][j] = dp[i - 1][j - 1] + (a[i] != a[j]); } } for(int i = l; i <= n; i ++) { for(int j = l; j <= n; j ++) { int x = dp[i][j] - dp[i - l][j - l]; prefix[x] ++ ; } answer[i - l + 1][0] = prefix[0]; for(int j = 1; j <= n; j ++) { prefix[j] += prefix[j - 1]; answer[i - l + 1][j] = prefix[j]; } for(int j = 0; j <= n; j ++) prefix[j] = 0; } cin >> q; while(q --) { int k; cin >> k; for(int i = 1; i <= n - l + 1; i ++) { cout << answer[i][k] - 1 << " "; } cout << "\n"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 4956 KB | Output is correct |
3 | Correct | 1 ms | 4956 KB | Output is correct |
4 | Correct | 1 ms | 4956 KB | Output is correct |
5 | Correct | 1 ms | 4956 KB | Output is correct |
6 | Correct | 1 ms | 4956 KB | Output is correct |
7 | Correct | 1 ms | 5072 KB | Output is correct |
8 | Correct | 1 ms | 4956 KB | Output is correct |
9 | Correct | 1 ms | 4956 KB | Output is correct |
10 | Correct | 1 ms | 5212 KB | Output is correct |
11 | Correct | 2 ms | 7004 KB | Output is correct |
12 | Correct | 2 ms | 5212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 4956 KB | Output is correct |
3 | Correct | 1 ms | 4956 KB | Output is correct |
4 | Correct | 1 ms | 4956 KB | Output is correct |
5 | Correct | 1 ms | 4956 KB | Output is correct |
6 | Correct | 1 ms | 4956 KB | Output is correct |
7 | Correct | 1 ms | 5072 KB | Output is correct |
8 | Correct | 1 ms | 4956 KB | Output is correct |
9 | Correct | 1 ms | 4956 KB | Output is correct |
10 | Correct | 1 ms | 5212 KB | Output is correct |
11 | Correct | 2 ms | 7004 KB | Output is correct |
12 | Correct | 2 ms | 5212 KB | Output is correct |
13 | Correct | 16 ms | 31780 KB | Output is correct |
14 | Correct | 14 ms | 28764 KB | Output is correct |
15 | Correct | 14 ms | 28632 KB | Output is correct |
16 | Correct | 18 ms | 30808 KB | Output is correct |
17 | Correct | 17 ms | 30808 KB | Output is correct |
18 | Correct | 17 ms | 30808 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 4956 KB | Output is correct |
3 | Correct | 1 ms | 4956 KB | Output is correct |
4 | Correct | 1 ms | 4956 KB | Output is correct |
5 | Correct | 1 ms | 4956 KB | Output is correct |
6 | Correct | 1 ms | 4956 KB | Output is correct |
7 | Correct | 1 ms | 5072 KB | Output is correct |
8 | Correct | 1 ms | 4956 KB | Output is correct |
9 | Correct | 1 ms | 4956 KB | Output is correct |
10 | Correct | 1 ms | 5212 KB | Output is correct |
11 | Correct | 2 ms | 7004 KB | Output is correct |
12 | Correct | 2 ms | 5212 KB | Output is correct |
13 | Correct | 16 ms | 31780 KB | Output is correct |
14 | Correct | 14 ms | 28764 KB | Output is correct |
15 | Correct | 14 ms | 28632 KB | Output is correct |
16 | Correct | 18 ms | 30808 KB | Output is correct |
17 | Correct | 17 ms | 30808 KB | Output is correct |
18 | Correct | 17 ms | 30808 KB | Output is correct |
19 | Incorrect | 0 ms | 348 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |