# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971598 | 2024-04-29T04:20:30 Z | vjudge1 | Abracadabra (CEOI22_abracadabra) | C++17 | 3000 ms | 35648 KB |
#include<bits/stdc++.h> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int N = 1e5 + 10; int n, q; int a[N], b[N], c[N], ans[N]; vector<pair<int, int> > query[N]; int32_t main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } if (fopen(task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } cin >> n >> q; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= q; i++) { int t, x; cin >> t >> x; query[min(n, t)].emplace_back(x, i); } b[n / 2 + 1] = c[n / 2 + 1] = 1e9; for(int turn = 0; turn <= n; turn++) { // for(int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl; for(auto &[x, i] : query[turn]) { ans[i] = a[x]; } for(int i = 1; i <= n / 2; i++) b[i] = a[i]; for(int i = n / 2 + 1; i <= n; i++) c[i - n / 2] = a[i]; // for(int i = 1; i <= n / 2; i++) cout << b[i] << " "; cout << endl; // for(int i = 1; i <= n / 2; i++) cout << c[i] << " "; cout << endl; for(int i = 1, j = 1; i <= n / 2 || j <= n / 2; ) { if (b[i] < c[j]) a[i + j - 1] = b[i], i++; else a[i + j - 1] = c[j], j++; } // for(int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl; } for(int i = 1; i <= q; i++) cout << ans[i] << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 120 ms | 35648 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 9 ms | 6744 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3029 ms | 8020 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 120 ms | 35648 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |