# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
867779 | 2023-10-29T12:54:49 Z | mariaclara | Abracadabra (CEOI22_abracadabra) | C++17 | 3000 ms | 41544 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pii; const int MAXN = 2e5+10; const int MAXQ = 1e6+10; const int MOD = 1e9+7; #define all(x) x.begin(), x.end() #define mk make_pair #define pb push_back #define f first #define s second int n, m, v[MAXN], a[MAXN], resp[MAXQ]; vector<pair<pii,int>> queries; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++) cin >> v[i]; for(int i = 1, a, b; i <= m; i++) { cin >> a >> b; queries.pb({{a,b},i}); } sort(all(queries)); bool mudou = 1; for(int i = 0, cnt = 0; mudou; i++) { for(; cnt < queries.size(); cnt++) { if(queries[cnt].f.f == i) resp[queries[cnt].s] = v[queries[cnt].f.s]; else break; } if(cnt > queries.size()) break; mudou = 0; for(int j = 1; j <= n; j++) a[j] = v[j]; int l=1, r=n/2+1; for( ; l <= n/2 and r <= n; ) { if(a[l] < a[r]) v[l+r-n/2-1] = a[l], l++; else v[l+r-n/2-1] = a[r], r++; } while(l <= n/2) v[l+r-n/2-1] = a[l], l++; while(r <= n) v[l+r-n/2-1] = a[r], r++; for(int j = 1; j <= n; j++){ if(v[j] != a[j]) mudou = 1; } } for(int i = 0; i < queries.size(); i++) { if(resp[queries[i].s] == 0) resp[queries[i].s] = v[queries[i].f.s]; } for(int i = 1; i <= m; i++) cout << resp[i] << "\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 271 ms | 40872 KB | Output is correct |
2 | Correct | 277 ms | 39592 KB | Output is correct |
3 | Correct | 286 ms | 39580 KB | Output is correct |
4 | Correct | 291 ms | 37784 KB | Output is correct |
5 | Correct | 288 ms | 40372 KB | Output is correct |
6 | Correct | 284 ms | 37468 KB | Output is correct |
7 | Correct | 272 ms | 40116 KB | Output is correct |
8 | Correct | 294 ms | 38312 KB | Output is correct |
9 | Correct | 259 ms | 38564 KB | Output is correct |
10 | Correct | 268 ms | 38816 KB | Output is correct |
11 | Correct | 280 ms | 38396 KB | Output is correct |
12 | Correct | 252 ms | 36772 KB | Output is correct |
13 | Correct | 275 ms | 37664 KB | Output is correct |
14 | Correct | 279 ms | 38904 KB | Output is correct |
15 | Correct | 295 ms | 39584 KB | Output is correct |
16 | Correct | 1 ms | 2392 KB | Output is correct |
17 | Correct | 269 ms | 38016 KB | Output is correct |
18 | Correct | 284 ms | 37540 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3074 ms | 41544 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 3024 ms | 9412 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 271 ms | 40872 KB | Output is correct |
2 | Correct | 277 ms | 39592 KB | Output is correct |
3 | Correct | 286 ms | 39580 KB | Output is correct |
4 | Correct | 291 ms | 37784 KB | Output is correct |
5 | Correct | 288 ms | 40372 KB | Output is correct |
6 | Correct | 284 ms | 37468 KB | Output is correct |
7 | Correct | 272 ms | 40116 KB | Output is correct |
8 | Correct | 294 ms | 38312 KB | Output is correct |
9 | Correct | 259 ms | 38564 KB | Output is correct |
10 | Correct | 268 ms | 38816 KB | Output is correct |
11 | Correct | 280 ms | 38396 KB | Output is correct |
12 | Correct | 252 ms | 36772 KB | Output is correct |
13 | Correct | 275 ms | 37664 KB | Output is correct |
14 | Correct | 279 ms | 38904 KB | Output is correct |
15 | Correct | 295 ms | 39584 KB | Output is correct |
16 | Correct | 1 ms | 2392 KB | Output is correct |
17 | Correct | 269 ms | 38016 KB | Output is correct |
18 | Correct | 284 ms | 37540 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Correct | 1 ms | 2396 KB | Output is correct |
21 | Execution timed out | 3074 ms | 41544 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |