# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631292 | 2022-08-18T02:49:05 Z | TranGiaHuy1508 | Brunhilda’s Birthday (BOI13_brunhilda) | C++17 | 861 ms | 262144 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 ll inf = 1e9; const ld eps = 1e-6; const int multitest = 0; const int maxval = 1e7 + 10; int dp[maxval]; vector<int> *divs[maxval]; void main_program(){ int m, Q; cin >> m >> Q; vi v(m); cin >> v; sort(all(v)); divs[0] = new vector<int>; for (int i = 0; i < m; i++) divs[0]->push_back(v[i]); for (int i = 0; i < maxval; i++){ dp[i] = inf; } queue<int> q; dp[0] = 0; q.push(0); int lim = 1; while (!q.empty()){ int x = q.front(); q.pop(); // for (int i = 0; i < min(m, 5); i++){ // if (x % v[i] == 0){ // for (; lim < min(x + v[i], maxval); lim++){ // dp[lim] = dp[x] + 1; q.push(lim); // } // } // } if (divs[x]){ for (auto i: *divs[x]){ for (; lim < min(x + i, maxval); lim++){ dp[lim] = dp[x] + 1; q.push(lim); if (!divs[lim]) divs[lim] = new vector<int>; divs[lim]->push_back(i); } } delete divs[x]; } } for (int i = 0; i < Q; i++){ int x; cin >> x; if (dp[x] == inf) cout << "oo\n"; else cout << dp[x] << "\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 | 438 ms | 117704 KB | Output isn't correct |
2 | Incorrect | 489 ms | 117708 KB | Output isn't correct |
3 | Incorrect | 460 ms | 117676 KB | Output isn't correct |
4 | Incorrect | 453 ms | 118148 KB | Output isn't correct |
5 | Incorrect | 469 ms | 117636 KB | Output isn't correct |
6 | Incorrect | 455 ms | 117624 KB | Output isn't correct |
7 | Incorrect | 516 ms | 117636 KB | Output isn't correct |
8 | Incorrect | 523 ms | 117708 KB | Output isn't correct |
9 | Incorrect | 492 ms | 117704 KB | Output isn't correct |
10 | Incorrect | 459 ms | 117760 KB | Output isn't correct |
11 | Incorrect | 455 ms | 117708 KB | Output isn't correct |
12 | Correct | 483 ms | 117980 KB | Output is correct |
13 | Correct | 547 ms | 118324 KB | Output is correct |
14 | Correct | 625 ms | 118344 KB | Output is correct |
15 | Incorrect | 461 ms | 117780 KB | Output isn't correct |
16 | Incorrect | 477 ms | 117756 KB | Output isn't correct |
17 | Incorrect | 457 ms | 117716 KB | Output isn't correct |
18 | Incorrect | 465 ms | 118160 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 663 ms | 177896 KB | Output isn't correct |
2 | Runtime error | 231 ms | 262144 KB | Execution killed with signal 9 |
3 | Runtime error | 445 ms | 262144 KB | Execution killed with signal 9 |
4 | Incorrect | 608 ms | 124476 KB | Output isn't correct |
5 | Incorrect | 685 ms | 204648 KB | Output isn't correct |
6 | Incorrect | 623 ms | 123088 KB | Output isn't correct |
7 | Incorrect | 686 ms | 177872 KB | Output isn't correct |
8 | Incorrect | 593 ms | 119712 KB | Output isn't correct |
9 | Correct | 738 ms | 204932 KB | Output is correct |
10 | Runtime error | 437 ms | 262144 KB | Execution killed with signal 9 |
11 | Incorrect | 612 ms | 178656 KB | Output isn't correct |
12 | Incorrect | 583 ms | 121336 KB | Output isn't correct |
13 | Correct | 579 ms | 151208 KB | Output is correct |
14 | Incorrect | 664 ms | 124372 KB | Output isn't correct |
15 | Correct | 676 ms | 171460 KB | Output is correct |
16 | Runtime error | 242 ms | 262144 KB | Execution killed with signal 9 |
17 | Incorrect | 502 ms | 122208 KB | Output isn't correct |
18 | Runtime error | 232 ms | 262144 KB | Execution killed with signal 9 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 707 ms | 184712 KB | Output isn't correct |
2 | Incorrect | 825 ms | 164804 KB | Output isn't correct |
3 | Incorrect | 596 ms | 182520 KB | Output isn't correct |
4 | Incorrect | 791 ms | 124740 KB | Output isn't correct |
5 | Runtime error | 233 ms | 262144 KB | Execution killed with signal 9 |
6 | Incorrect | 748 ms | 126680 KB | Output isn't correct |
7 | Runtime error | 364 ms | 262144 KB | Execution killed with signal 9 |
8 | Incorrect | 707 ms | 184748 KB | Output isn't correct |
9 | Incorrect | 675 ms | 184760 KB | Output isn't correct |
10 | Incorrect | 782 ms | 124416 KB | Output isn't correct |
11 | Incorrect | 735 ms | 124452 KB | Output isn't correct |
12 | Incorrect | 654 ms | 124540 KB | Output isn't correct |
13 | Incorrect | 596 ms | 170820 KB | Output isn't correct |
14 | Incorrect | 541 ms | 118216 KB | Output isn't correct |
15 | Incorrect | 790 ms | 123136 KB | Output isn't correct |
16 | Incorrect | 813 ms | 123160 KB | Output isn't correct |
17 | Incorrect | 764 ms | 171556 KB | Output isn't correct |
18 | Incorrect | 710 ms | 164880 KB | Output isn't correct |
19 | Incorrect | 609 ms | 164640 KB | Output isn't correct |
20 | Incorrect | 581 ms | 182508 KB | Output isn't correct |
21 | Incorrect | 554 ms | 118240 KB | Output isn't correct |
22 | Incorrect | 765 ms | 218584 KB | Output isn't correct |
23 | Incorrect | 729 ms | 184860 KB | Output isn't correct |
24 | Incorrect | 546 ms | 124656 KB | Output isn't correct |
25 | Incorrect | 755 ms | 121396 KB | Output isn't correct |
26 | Incorrect | 787 ms | 124668 KB | Output isn't correct |
27 | Incorrect | 735 ms | 227832 KB | Output isn't correct |
28 | Incorrect | 547 ms | 131132 KB | Output isn't correct |
29 | Incorrect | 769 ms | 218708 KB | Output isn't correct |
30 | Incorrect | 753 ms | 185016 KB | Output isn't correct |
31 | Incorrect | 620 ms | 138032 KB | Output isn't correct |
32 | Incorrect | 687 ms | 123944 KB | Output isn't correct |
33 | Incorrect | 655 ms | 131532 KB | Output isn't correct |
34 | Runtime error | 321 ms | 262144 KB | Execution killed with signal 9 |
35 | Incorrect | 527 ms | 129700 KB | Output isn't correct |
36 | Incorrect | 749 ms | 218648 KB | Output isn't correct |
37 | Runtime error | 231 ms | 262144 KB | Execution killed with signal 9 |
38 | Incorrect | 758 ms | 126644 KB | Output isn't correct |
39 | Incorrect | 692 ms | 126028 KB | Output isn't correct |
40 | Incorrect | 861 ms | 131348 KB | Output isn't correct |
41 | Runtime error | 237 ms | 262144 KB | Execution killed with signal 9 |
42 | Incorrect | 542 ms | 121684 KB | Output isn't correct |