Submission #711984

# Submission time Handle Problem Language Result Execution time Memory
711984 2023-03-17T20:04:40 Z stevancv Brunhilda’s Birthday (BOI13_brunhilda) C++14
0 / 100
86 ms 79864 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int M = 1e6 + 2;
const int inf = 1e9;
vector<int> primes[M];
int idx[M], ans[N], koji[M], dp[M];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, q;
    cin >> n >> q;
    multiset<pair<int, int>> s;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        s.insert({0, x});
        for (int j = x; j < 1e7; j += x) primes[j].push_back(x);
    }
    for (int i = 1; i <= q; i++) {
        int x; cin >> x;
        idx[x] = i;
    }
    for (int i = 1; i < M; i++) {
        dp[i] = inf;
        for (int j : primes[i]) {
            s.erase({koji[j], j});
        }
        if (!s.empty()) dp[i] = s.begin()->first + 1;
        if (idx[i] != 0) ans[idx[i]] = dp[i];
        for (int j : primes[i]) {
            s.insert({dp[i], j});
            koji[j] = dp[i];
        }
    }
    for (int i = 1; i <= q; i++) {
        if (ans[i] >= inf) cout << "oo" << en;
        else cout << ans[i] << en;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 53068 KB Execution killed with signal 6
2 Runtime error 67 ms 79764 KB Execution killed with signal 11
3 Runtime error 63 ms 79792 KB Execution killed with signal 11
4 Runtime error 34 ms 48496 KB Execution killed with signal 11
5 Runtime error 43 ms 53836 KB Execution killed with signal 11
6 Runtime error 40 ms 53068 KB Execution killed with signal 6
7 Runtime error 67 ms 79712 KB Execution killed with signal 11
8 Runtime error 61 ms 79780 KB Execution killed with signal 11
9 Runtime error 62 ms 79740 KB Execution killed with signal 11
10 Runtime error 70 ms 79820 KB Execution killed with signal 11
11 Runtime error 55 ms 69220 KB Execution killed with signal 11
12 Runtime error 35 ms 48076 KB Execution killed with signal 11
13 Runtime error 64 ms 79740 KB Execution killed with signal 11
14 Runtime error 66 ms 79756 KB Execution killed with signal 11
15 Runtime error 82 ms 79788 KB Execution killed with signal 11
16 Runtime error 86 ms 79736 KB Execution killed with signal 11
17 Runtime error 39 ms 49748 KB Execution killed with signal 6
18 Runtime error 32 ms 48496 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 48656 KB Execution killed with signal 11
2 Runtime error 36 ms 49868 KB Execution killed with signal 6
3 Runtime error 68 ms 79764 KB Execution killed with signal 11
4 Runtime error 48 ms 57152 KB Execution killed with signal 11
5 Runtime error 57 ms 69220 KB Execution killed with signal 11
6 Runtime error 70 ms 79804 KB Execution killed with signal 11
7 Runtime error 34 ms 48620 KB Execution killed with signal 11
8 Runtime error 40 ms 53856 KB Execution killed with signal 11
9 Runtime error 59 ms 69144 KB Execution killed with signal 11
10 Runtime error 67 ms 79800 KB Execution killed with signal 11
11 Runtime error 61 ms 79792 KB Execution killed with signal 11
12 Runtime error 76 ms 79844 KB Execution killed with signal 11
13 Runtime error 42 ms 57104 KB Execution killed with signal 11
14 Runtime error 49 ms 57124 KB Execution killed with signal 11
15 Runtime error 62 ms 79812 KB Execution killed with signal 11
16 Runtime error 35 ms 49968 KB Execution killed with signal 6
17 Runtime error 63 ms 79712 KB Execution killed with signal 11
18 Runtime error 55 ms 69208 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Runtime error 84 ms 79760 KB Execution killed with signal 11
2 Runtime error 68 ms 79812 KB Execution killed with signal 11
3 Runtime error 69 ms 79768 KB Execution killed with signal 11
4 Runtime error 82 ms 79864 KB Execution killed with signal 11
5 Runtime error 38 ms 48076 KB Execution killed with signal 11
6 Runtime error 63 ms 79780 KB Execution killed with signal 11
7 Runtime error 38 ms 51916 KB Execution killed with signal 6
8 Runtime error 63 ms 79792 KB Execution killed with signal 11
9 Runtime error 61 ms 79732 KB Execution killed with signal 11
10 Runtime error 62 ms 60876 KB Execution killed with signal 6
11 Runtime error 47 ms 60864 KB Execution killed with signal 6
12 Runtime error 71 ms 79748 KB Execution killed with signal 11
13 Runtime error 65 ms 79724 KB Execution killed with signal 11
14 Runtime error 66 ms 79728 KB Execution killed with signal 11
15 Runtime error 80 ms 79696 KB Execution killed with signal 11
16 Runtime error 63 ms 79700 KB Execution killed with signal 11
17 Runtime error 57 ms 69196 KB Execution killed with signal 11
18 Runtime error 65 ms 79828 KB Execution killed with signal 11
19 Runtime error 52 ms 69148 KB Execution killed with signal 11
20 Runtime error 62 ms 79820 KB Execution killed with signal 11
21 Runtime error 65 ms 79732 KB Execution killed with signal 11
22 Runtime error 70 ms 79744 KB Execution killed with signal 11
23 Runtime error 32 ms 48036 KB Execution killed with signal 11
24 Runtime error 36 ms 51360 KB Execution killed with signal 11
25 Runtime error 56 ms 69168 KB Execution killed with signal 11
26 Runtime error 63 ms 79820 KB Execution killed with signal 11
27 Runtime error 69 ms 79716 KB Execution killed with signal 11
28 Runtime error 49 ms 60816 KB Execution killed with signal 6
29 Runtime error 40 ms 53004 KB Execution killed with signal 6
30 Runtime error 40 ms 50260 KB Execution killed with signal 11
31 Runtime error 44 ms 57052 KB Execution killed with signal 11
32 Runtime error 49 ms 60968 KB Execution killed with signal 6
33 Runtime error 35 ms 51396 KB Execution killed with signal 11
34 Runtime error 39 ms 51948 KB Execution killed with signal 6
35 Runtime error 50 ms 60868 KB Execution killed with signal 6
36 Runtime error 72 ms 79708 KB Execution killed with signal 11
37 Runtime error 35 ms 48076 KB Execution killed with signal 11
38 Runtime error 71 ms 79716 KB Execution killed with signal 11
39 Runtime error 37 ms 51412 KB Execution killed with signal 11
40 Runtime error 63 ms 79788 KB Execution killed with signal 11
41 Runtime error 69 ms 79816 KB Execution killed with signal 11
42 Runtime error 61 ms 79732 KB Execution killed with signal 11