# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
916498 | 2024-01-26T02:38:27 Z | knatwila | Abracadabra (CEOI22_abracadabra) | C++17 | 794 ms | 524288 KB |
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define sz(x) (x).size() #define F first #define S second #define left(v) (v) + (v) #define right(v) (v) + (v) + 1 #define ll long long #define int long long using namespace std; ///using ll = long long; //using ull = unsigned long long; const int MAXN = 1e6 + 5; const int inf = 4e9; const long long INF = 1e16; const int M = 998244353; const int K = 300; const int K2 = 600; const int P = 191; const int P2 = 191; const double EPS = 1e-12; void D_BASE(string name = "") { if (sz(name)) { freopen((name + ".in").c_str(), "r", stdin); freopen((name + ".out").c_str(), "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } //13 20 int n, q; int a[MAXN]; vector<int> g[MAXN]; void solve() { cin >> n >> q; for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 1; i <= n; ++i) g[0].pb(a[i]); int pos = 0; while (true) { pos++; vector<int> x, y; for (int i = 1; i <= n; ++i) { if(i <= n / 2) x.pb(a[i]); else y.pb(a[i]); } int posx = 0, posy = 0; while (posx < sz(x) && posy < sz(y)) { if(x[posx] < y[posy]) { g[pos].pb(x[posx]); posx++; } else { g[pos].pb(y[posy]); posy++; } } while (posx < sz(x)) { g[pos].pb(x[posx]); posx++; } while (posy < sz(y)) { g[pos].pb(y[posy]); posy++; } bool check = 1; for (int i = 1; i <= n; ++i) { if(a[i] != g[pos][i - 1]) check = 0; a[i] = g[pos][i - 1]; } if(check) break; } while (q--) { int x, y; cin >> x >> y; int curpos = min(pos, x); cout << g[curpos][y - 1] << '\n'; } } signed main() { D_BASE(""); int tt = 1, ct = 0; //cin >> tt; while (tt--) { //cout << "Case " << ++ct << ":\n"; solve(); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 193 ms | 44884 KB | Output is correct |
2 | Correct | 169 ms | 38484 KB | Output is correct |
3 | Correct | 168 ms | 40008 KB | Output is correct |
4 | Correct | 150 ms | 35156 KB | Output is correct |
5 | Correct | 175 ms | 37460 KB | Output is correct |
6 | Correct | 152 ms | 36068 KB | Output is correct |
7 | Correct | 165 ms | 37972 KB | Output is correct |
8 | Correct | 153 ms | 35928 KB | Output is correct |
9 | Correct | 155 ms | 35668 KB | Output is correct |
10 | Correct | 160 ms | 35924 KB | Output is correct |
11 | Correct | 153 ms | 35968 KB | Output is correct |
12 | Correct | 152 ms | 34696 KB | Output is correct |
13 | Correct | 156 ms | 35156 KB | Output is correct |
14 | Correct | 160 ms | 36672 KB | Output is correct |
15 | Correct | 182 ms | 35604 KB | Output is correct |
16 | Correct | 8 ms | 25244 KB | Output is correct |
17 | Correct | 145 ms | 34644 KB | Output is correct |
18 | Correct | 148 ms | 34496 KB | Output is correct |
19 | Correct | 6 ms | 25180 KB | Output is correct |
20 | Correct | 7 ms | 25180 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 794 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 715 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 193 ms | 44884 KB | Output is correct |
2 | Correct | 169 ms | 38484 KB | Output is correct |
3 | Correct | 168 ms | 40008 KB | Output is correct |
4 | Correct | 150 ms | 35156 KB | Output is correct |
5 | Correct | 175 ms | 37460 KB | Output is correct |
6 | Correct | 152 ms | 36068 KB | Output is correct |
7 | Correct | 165 ms | 37972 KB | Output is correct |
8 | Correct | 153 ms | 35928 KB | Output is correct |
9 | Correct | 155 ms | 35668 KB | Output is correct |
10 | Correct | 160 ms | 35924 KB | Output is correct |
11 | Correct | 153 ms | 35968 KB | Output is correct |
12 | Correct | 152 ms | 34696 KB | Output is correct |
13 | Correct | 156 ms | 35156 KB | Output is correct |
14 | Correct | 160 ms | 36672 KB | Output is correct |
15 | Correct | 182 ms | 35604 KB | Output is correct |
16 | Correct | 8 ms | 25244 KB | Output is correct |
17 | Correct | 145 ms | 34644 KB | Output is correct |
18 | Correct | 148 ms | 34496 KB | Output is correct |
19 | Correct | 6 ms | 25180 KB | Output is correct |
20 | Correct | 7 ms | 25180 KB | Output is correct |
21 | Runtime error | 794 ms | 524288 KB | Execution killed with signal 9 |
22 | Halted | 0 ms | 0 KB | - |