# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
558909 | 2022-05-09T00:07:40 Z | Olympia | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 991 ms | 80788 KB |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int M, Q; cin >> M >> Q; vector<int> p(M); for (int i = 0; i < M; i++) { cin >> p[i]; } int mx = 10000000; int res[mx]; int lpf[mx]; for (int i = 0; i < mx; i++) { lpf[i] = -1; } for (int j = 0; j < p.size(); j++) { for (int i = p[j]; i < mx; i += p[j]) { lpf[i] = j; } } int dp[M]; priority_queue<int, vector<int>, greater<int> > ms; for (int i = 0; i < M; i++) { dp[i] = 0; ms.push(dp[i]); } for (int i = 1; i < mx; i++) { int ans = 1e9; if (lpf[i] == -1) { ans = ms.top() + 1; } else { vector<int> invalid; int x = i; while (lpf[x] != -1) { if (dp[lpf[x]] == ms.top()) { invalid.push_back(lpf[x]); ms.pop(); } int a = p[lpf[x]]; while (x % a == 0) { x /= a; } } if (!ms.empty()) { ans = ms.top() + 1; } for (int j: invalid) { dp[j] = ans; ms.push(dp[j]); } } res[i] = ans; } while (Q--) { int x; cin >> x; if (res[x] == (int)1e9) { cout << "oo\n"; } else { cout << res[x] << '\n'; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 158 ms | 78568 KB | Output isn't correct |
2 | Correct | 535 ms | 78576 KB | Output is correct |
3 | Correct | 414 ms | 78564 KB | Output is correct |
4 | Correct | 105 ms | 78576 KB | Output is correct |
5 | Correct | 211 ms | 78572 KB | Output is correct |
6 | Incorrect | 170 ms | 78572 KB | Output isn't correct |
7 | Correct | 421 ms | 78572 KB | Output is correct |
8 | Correct | 616 ms | 78572 KB | Output is correct |
9 | Correct | 778 ms | 78568 KB | Output is correct |
10 | Correct | 794 ms | 78576 KB | Output is correct |
11 | Correct | 513 ms | 78668 KB | Output is correct |
12 | Correct | 99 ms | 78572 KB | Output is correct |
13 | Correct | 979 ms | 78700 KB | Output is correct |
14 | Correct | 943 ms | 78592 KB | Output is correct |
15 | Correct | 505 ms | 78564 KB | Output is correct |
16 | Correct | 530 ms | 78668 KB | Output is correct |
17 | Correct | 205 ms | 78576 KB | Output is correct |
18 | Correct | 92 ms | 78568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 78776 KB | Output is correct |
2 | Correct | 159 ms | 79844 KB | Output is correct |
3 | Correct | 919 ms | 79780 KB | Output is correct |
4 | Correct | 217 ms | 78544 KB | Output is correct |
5 | Correct | 552 ms | 79340 KB | Output is correct |
6 | Correct | 376 ms | 78540 KB | Output is correct |
7 | Correct | 112 ms | 78876 KB | Output is correct |
8 | Correct | 207 ms | 78564 KB | Output is correct |
9 | Correct | 613 ms | 79776 KB | Output is correct |
10 | Correct | 963 ms | 79764 KB | Output is correct |
11 | Correct | 920 ms | 79344 KB | Output is correct |
12 | Correct | 537 ms | 78616 KB | Output is correct |
13 | Correct | 135 ms | 78628 KB | Output is correct |
14 | Correct | 224 ms | 78628 KB | Output is correct |
15 | Correct | 834 ms | 79256 KB | Output is correct |
16 | Correct | 146 ms | 79952 KB | Output is correct |
17 | Correct | 892 ms | 78584 KB | Output is correct |
18 | Incorrect | 647 ms | 80000 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 853 ms | 79436 KB | Output is correct |
2 | Correct | 936 ms | 79340 KB | Output is correct |
3 | Correct | 991 ms | 79696 KB | Output is correct |
4 | Correct | 615 ms | 78884 KB | Output is correct |
5 | Correct | 163 ms | 80012 KB | Output is correct |
6 | Correct | 804 ms | 78868 KB | Output is correct |
7 | Correct | 386 ms | 80008 KB | Output is correct |
8 | Correct | 896 ms | 79436 KB | Output is correct |
9 | Correct | 874 ms | 79436 KB | Output is correct |
10 | Correct | 436 ms | 78668 KB | Output is correct |
11 | Correct | 379 ms | 78668 KB | Output is correct |
12 | Correct | 741 ms | 78844 KB | Output is correct |
13 | Correct | 840 ms | 79836 KB | Output is correct |
14 | Correct | 854 ms | 79720 KB | Output is correct |
15 | Correct | 859 ms | 78728 KB | Output is correct |
16 | Correct | 909 ms | 78756 KB | Output is correct |
17 | Correct | 549 ms | 79308 KB | Output is correct |
18 | Correct | 953 ms | 79344 KB | Output is correct |
19 | Correct | 215 ms | 78712 KB | Output is correct |
20 | Correct | 953 ms | 79696 KB | Output is correct |
21 | Incorrect | 854 ms | 79088 KB | Output isn't correct |
22 | Correct | 924 ms | 80788 KB | Output is correct |
23 | Correct | 172 ms | 79192 KB | Output is correct |
24 | Correct | 140 ms | 78856 KB | Output is correct |
25 | Correct | 542 ms | 78924 KB | Output is correct |
26 | Correct | 577 ms | 78976 KB | Output is correct |
27 | Correct | 944 ms | 80348 KB | Output is correct |
28 | Incorrect | 188 ms | 78796 KB | Output isn't correct |
29 | Correct | 518 ms | 80028 KB | Output is correct |
30 | Correct | 459 ms | 79696 KB | Output is correct |
31 | Correct | 213 ms | 78792 KB | Output is correct |
32 | Correct | 278 ms | 78796 KB | Output is correct |
33 | Correct | 113 ms | 78852 KB | Output is correct |
34 | Correct | 368 ms | 80004 KB | Output is correct |
35 | Incorrect | 199 ms | 78868 KB | Output isn't correct |
36 | Correct | 903 ms | 80548 KB | Output is correct |
37 | Correct | 165 ms | 80004 KB | Output is correct |
38 | Correct | 749 ms | 78988 KB | Output is correct |
39 | Correct | 162 ms | 78800 KB | Output is correct |
40 | Correct | 640 ms | 79056 KB | Output is correct |
41 | Correct | 515 ms | 80008 KB | Output is correct |
42 | Incorrect | 901 ms | 79272 KB | Output isn't correct |