# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631347 | 2022-08-18T03:30:14 Z | TranGiaHuy1508 | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 1000 ms | 107408 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; void sieve(){ for (int d = 2; d < maxval; d++){ if (!divs[d]){ divs[d] = d; primes.pb(d); for (int j = 0; j < sz(primes) && primes[j] <= d; j++){ if (d * primes[j] >= maxval) break; divs[d * primes[j]] = primes[j]; } } } } #define chkmin(a, b) ((a) < (b) ? (a) : (b)) void main_program(){ int m, Q; cin >> m >> Q; vi inp(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++; } for (int i = 0; i < Q; i++){ int a; cin >> a; if (dp[a] >= inf) 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 285 ms | 98448 KB | Output isn't correct |
2 | Incorrect | 281 ms | 98292 KB | Output isn't correct |
3 | Incorrect | 254 ms | 98268 KB | Output isn't correct |
4 | Correct | 401 ms | 98276 KB | Output is correct |
5 | Correct | 256 ms | 98432 KB | Output is correct |
6 | Incorrect | 266 ms | 98256 KB | Output isn't correct |
7 | Incorrect | 273 ms | 98444 KB | Output isn't correct |
8 | Incorrect | 273 ms | 98348 KB | Output isn't correct |
9 | Incorrect | 261 ms | 98228 KB | Output isn't correct |
10 | Incorrect | 279 ms | 98320 KB | Output isn't correct |
11 | Incorrect | 255 ms | 98244 KB | Output isn't correct |
12 | Correct | 403 ms | 98264 KB | Output is correct |
13 | Correct | 376 ms | 98312 KB | Output is correct |
14 | Correct | 385 ms | 98288 KB | Output is correct |
15 | Incorrect | 272 ms | 98300 KB | Output isn't correct |
16 | Incorrect | 289 ms | 98244 KB | Output isn't correct |
17 | Incorrect | 256 ms | 98260 KB | Output isn't correct |
18 | Correct | 393 ms | 98364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1095 ms | 99172 KB | Time limit exceeded |
2 | Execution timed out | 1091 ms | 107408 KB | Time limit exceeded |
3 | Execution timed out | 1101 ms | 99588 KB | Time limit exceeded |
4 | Incorrect | 703 ms | 98532 KB | Output isn't correct |
5 | Execution timed out | 1102 ms | 99684 KB | Time limit exceeded |
6 | Incorrect | 499 ms | 98392 KB | Output isn't correct |
7 | Execution timed out | 1097 ms | 99216 KB | Time limit exceeded |
8 | Incorrect | 420 ms | 98324 KB | Output isn't correct |
9 | Execution timed out | 1091 ms | 99852 KB | Time limit exceeded |
10 | Execution timed out | 1092 ms | 99616 KB | Time limit exceeded |
11 | Execution timed out | 1092 ms | 98868 KB | Time limit exceeded |
12 | Incorrect | 493 ms | 98372 KB | Output isn't correct |
13 | Execution timed out | 1087 ms | 98884 KB | Time limit exceeded |
14 | Incorrect | 732 ms | 98580 KB | Output isn't correct |
15 | Execution timed out | 1097 ms | 99264 KB | Time limit exceeded |
16 | Execution timed out | 1094 ms | 107408 KB | Time limit exceeded |
17 | Incorrect | 603 ms | 98364 KB | Output isn't correct |
18 | Execution timed out | 1097 ms | 100596 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1103 ms | 99380 KB | Time limit exceeded |
2 | Execution timed out | 1053 ms | 99148 KB | Time limit exceeded |
3 | Execution timed out | 1104 ms | 99164 KB | Time limit exceeded |
4 | Incorrect | 750 ms | 98720 KB | Output isn't correct |
5 | Execution timed out | 1103 ms | 102968 KB | Time limit exceeded |
6 | Execution timed out | 1096 ms | 98432 KB | Time limit exceeded |
7 | Execution timed out | 1095 ms | 100840 KB | Time limit exceeded |
8 | Execution timed out | 1088 ms | 99392 KB | Time limit exceeded |
9 | Execution timed out | 1086 ms | 99512 KB | Time limit exceeded |
10 | Execution timed out | 1002 ms | 98500 KB | Time limit exceeded |
11 | Incorrect | 864 ms | 98428 KB | Output isn't correct |
12 | Execution timed out | 1087 ms | 98452 KB | Time limit exceeded |
13 | Execution timed out | 1097 ms | 98696 KB | Time limit exceeded |
14 | Incorrect | 275 ms | 98560 KB | Output isn't correct |
15 | Incorrect | 866 ms | 98420 KB | Output isn't correct |
16 | Execution timed out | 1006 ms | 98444 KB | Time limit exceeded |
17 | Execution timed out | 1101 ms | 99248 KB | Time limit exceeded |
18 | Execution timed out | 1095 ms | 99240 KB | Time limit exceeded |
19 | Execution timed out | 1068 ms | 98944 KB | Time limit exceeded |
20 | Execution timed out | 1097 ms | 99088 KB | Time limit exceeded |
21 | Incorrect | 325 ms | 98556 KB | Output isn't correct |
22 | Execution timed out | 1095 ms | 100164 KB | Time limit exceeded |
23 | Execution timed out | 1095 ms | 99296 KB | Time limit exceeded |
24 | Incorrect | 590 ms | 98784 KB | Output isn't correct |
25 | Incorrect | 597 ms | 98628 KB | Output isn't correct |
26 | Incorrect | 748 ms | 98688 KB | Output isn't correct |
27 | Execution timed out | 1097 ms | 99956 KB | Time limit exceeded |
28 | Incorrect | 650 ms | 98808 KB | Output isn't correct |
29 | Execution timed out | 1081 ms | 100352 KB | Time limit exceeded |
30 | Execution timed out | 1058 ms | 99644 KB | Time limit exceeded |
31 | Execution timed out | 1092 ms | 98580 KB | Time limit exceeded |
32 | Incorrect | 678 ms | 98772 KB | Output isn't correct |
33 | Incorrect | 661 ms | 98932 KB | Output isn't correct |
34 | Execution timed out | 1086 ms | 100948 KB | Time limit exceeded |
35 | Incorrect | 775 ms | 98752 KB | Output isn't correct |
36 | Execution timed out | 1086 ms | 100184 KB | Time limit exceeded |
37 | Execution timed out | 1091 ms | 103024 KB | Time limit exceeded |
38 | Execution timed out | 1100 ms | 98420 KB | Time limit exceeded |
39 | Incorrect | 698 ms | 98688 KB | Output isn't correct |
40 | Execution timed out | 1096 ms | 98732 KB | Time limit exceeded |
41 | Execution timed out | 1094 ms | 101880 KB | Time limit exceeded |
42 | Incorrect | 541 ms | 98732 KB | Output isn't correct |