# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
631355 | 2022-08-18T03:37:37 Z | TranGiaHuy1508 | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 1000 ms | 87748 KB |
/* Unknown's C++ Template (v3.2) */ #include "bits/stdc++.h" using namespace std; // #define int long long using ll = long long; using ld = long double; using ii = pair<int, int>; using vi = vector<int>; using vii = vector<ii>; using vvi = vector<vi>; using vvii = vector<vii>; template <class T> using maxpq = priority_queue<T>; template <class T> using minpq = priority_queue<T, vector<T>, greater<T>>; #define pb push_back #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define mid ((l+r)>>1) #define fi first #define se second #ifdef LOCAL #define debug(x) cout << #x << " = " << x << "\n"; #else #define debug(x) ; #endif template <class A, class B> ostream& operator << (ostream& out, pair<A, B> x) { out << "(" << x.first << ", " << x.second << ")"; return out; } template <class T> ostream& operator << (ostream& out, vector<T> x){ out << "["; for (int i=0; i<sz(x); i++) { out << (i ? ", " : "") << x[i]; } out << "]"; return out; } template <class T> istream& operator >> (istream& in, vector<T> &x){ for (auto &i: x) in >> i; return in; } const ld PI = acos(-1.0); const int allmod[3] = {(int)1e9+7, 998244353, (int)1e9+9}; const int mod = allmod[0]; const int maxn = 2e5 + 64; const int inf = 1e9; const ld eps = 1e-6; const int multitest = 0; const int maxval = 1e7 + 10; int dp[maxval]; bool v[maxval]; int divs[maxval]; vi primes, inp; void sieve(){ for (auto i: inp){ for (int j = i; j < maxval; j += i) divs[j] = i; } } #define chkmin(a, b) ((a) < (b) ? (a) : (b)) void main_program(){ int m, Q; cin >> m >> Q; inp.resize(m); cin >> inp; for (int i = 0; i < m; i++){ int x = inp[i]; v[x] = true; } sieve(); for (int i = 0; i < maxval; i++){ dp[i] = inf; } dp[0] = 0; for (int i = 1; i < *max_element(all(inp)); i++) dp[i] = 1; int x = 0; int lim = *max_element(all(inp)); while (x < maxval && lim < maxval){ if (x >= lim) break; int j = x; while (j > 1){ int p = divs[j]; if (!p) break; if (v[p]){ while (lim < chkmin(maxval, x + p)){ dp[lim] = dp[x] + 1; // if (lim <= 10) cout << lim << " " << dp[lim] << "\n"; lim++; } } j /= p; } x++; } // cout << lim << "\n"; for (int i = 0; i < Q; i++){ int a; cin >> a; if (a >= lim) cout << "oo\n"; else cout << dp[a] << "\n"; } } void pre_main(){ } signed main(){ #ifdef LOCAL auto stime = chrono::high_resolution_clock::now(); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef ONLINE_JUDGE if (fopen(".inp", "r")){ freopen(".inp", "r", stdin); freopen(".out", "w", stdout); } #endif int t = 1; if (multitest) cin >> t; pre_main(); while (t--) main_program(); #ifdef LOCAL auto etime = chrono::high_resolution_clock::now(); auto duration = chrono::duration_cast<chrono::milliseconds>(etime-stime).count(); cout << "\n[" << duration << "ms]\n"; #endif }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 41 ms | 78592 KB | Output is correct |
2 | Correct | 272 ms | 78544 KB | Output is correct |
3 | Correct | 50 ms | 78496 KB | Output is correct |
4 | Correct | 69 ms | 78504 KB | Output is correct |
5 | Correct | 117 ms | 78552 KB | Output is correct |
6 | Correct | 60 ms | 78560 KB | Output is correct |
7 | Correct | 53 ms | 78624 KB | Output is correct |
8 | Correct | 70 ms | 78492 KB | Output is correct |
9 | Correct | 360 ms | 78584 KB | Output is correct |
10 | Correct | 382 ms | 78540 KB | Output is correct |
11 | Correct | 272 ms | 78660 KB | Output is correct |
12 | Correct | 69 ms | 78480 KB | Output is correct |
13 | Correct | 511 ms | 78596 KB | Output is correct |
14 | Correct | 491 ms | 78668 KB | Output is correct |
15 | Correct | 250 ms | 78612 KB | Output is correct |
16 | Correct | 283 ms | 78496 KB | Output is correct |
17 | Correct | 112 ms | 78592 KB | Output is correct |
18 | Correct | 74 ms | 78588 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1100 ms | 79412 KB | Time limit exceeded |
2 | Execution timed out | 1104 ms | 87640 KB | Time limit exceeded |
3 | Execution timed out | 1074 ms | 79820 KB | Time limit exceeded |
4 | Correct | 453 ms | 78700 KB | Output is correct |
5 | Execution timed out | 1094 ms | 79976 KB | Time limit exceeded |
6 | Correct | 276 ms | 78672 KB | Output is correct |
7 | Execution timed out | 1074 ms | 79452 KB | Time limit exceeded |
8 | Correct | 181 ms | 78624 KB | Output is correct |
9 | Execution timed out | 1087 ms | 80052 KB | Time limit exceeded |
10 | Execution timed out | 1088 ms | 79764 KB | Time limit exceeded |
11 | Execution timed out | 1084 ms | 79160 KB | Time limit exceeded |
12 | Correct | 402 ms | 78544 KB | Output is correct |
13 | Execution timed out | 1092 ms | 78992 KB | Time limit exceeded |
14 | Correct | 452 ms | 78612 KB | Output is correct |
15 | Execution timed out | 1075 ms | 79464 KB | Time limit exceeded |
16 | Execution timed out | 1097 ms | 87748 KB | Time limit exceeded |
17 | Correct | 665 ms | 78632 KB | Output is correct |
18 | Execution timed out | 1087 ms | 80876 KB | Time limit exceeded |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 79676 KB | Time limit exceeded |
2 | Execution timed out | 1096 ms | 79396 KB | Time limit exceeded |
3 | Execution timed out | 1093 ms | 79348 KB | Time limit exceeded |
4 | Correct | 687 ms | 78956 KB | Output is correct |
5 | Execution timed out | 1086 ms | 83228 KB | Time limit exceeded |
6 | Execution timed out | 1098 ms | 78656 KB | Time limit exceeded |
7 | Execution timed out | 1096 ms | 81148 KB | Time limit exceeded |
8 | Execution timed out | 1089 ms | 79672 KB | Time limit exceeded |
9 | Execution timed out | 1101 ms | 79760 KB | Time limit exceeded |
10 | Correct | 859 ms | 78712 KB | Output is correct |
11 | Correct | 645 ms | 78700 KB | Output is correct |
12 | Correct | 978 ms | 78708 KB | Output is correct |
13 | Execution timed out | 1105 ms | 79004 KB | Time limit exceeded |
14 | Correct | 415 ms | 79096 KB | Output is correct |
15 | Correct | 887 ms | 78692 KB | Output is correct |
16 | Execution timed out | 1012 ms | 78692 KB | Time limit exceeded |
17 | Execution timed out | 1071 ms | 79456 KB | Time limit exceeded |
18 | Execution timed out | 1082 ms | 79392 KB | Time limit exceeded |
19 | Execution timed out | 1096 ms | 79180 KB | Time limit exceeded |
20 | Execution timed out | 1093 ms | 79352 KB | Time limit exceeded |
21 | Correct | 457 ms | 79124 KB | Output is correct |
22 | Execution timed out | 1101 ms | 80360 KB | Time limit exceeded |
23 | Execution timed out | 1096 ms | 79684 KB | Time limit exceeded |
24 | Correct | 233 ms | 78856 KB | Output is correct |
25 | Correct | 473 ms | 78896 KB | Output is correct |
26 | Correct | 709 ms | 78860 KB | Output is correct |
27 | Execution timed out | 1084 ms | 80184 KB | Time limit exceeded |
28 | Correct | 332 ms | 78956 KB | Output is correct |
29 | Execution timed out | 1095 ms | 80396 KB | Time limit exceeded |
30 | Execution timed out | 1094 ms | 79752 KB | Time limit exceeded |
31 | Execution timed out | 1090 ms | 78816 KB | Time limit exceeded |
32 | Correct | 439 ms | 78944 KB | Output is correct |
33 | Correct | 329 ms | 79040 KB | Output is correct |
34 | Execution timed out | 1094 ms | 81276 KB | Time limit exceeded |
35 | Correct | 493 ms | 78960 KB | Output is correct |
36 | Execution timed out | 1089 ms | 80332 KB | Time limit exceeded |
37 | Execution timed out | 1090 ms | 83276 KB | Time limit exceeded |
38 | Execution timed out | 1092 ms | 78788 KB | Time limit exceeded |
39 | Correct | 405 ms | 78968 KB | Output is correct |
40 | Execution timed out | 1099 ms | 78796 KB | Time limit exceeded |
41 | Execution timed out | 1071 ms | 82112 KB | Time limit exceeded |
42 | Correct | 648 ms | 79016 KB | Output is correct |