답안 #865552

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
865552 2023-10-24T09:57:34 Z mychecksedad Abracadabra (CEOI22_abracadabra) C++17
10 / 100
3000 ms 29492 KB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;

int n, q, ans[N];
vector<array<int, 3>> Q;
void solve(){
  cin >> n >> q;
  vector<int> a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < q; ++i){
    int t, x; cin >> t  >> x;
    Q.pb({t, x - 1, i});
  }
  sort(all(Q));
  bool ok = 1;
  int t = 0;
  int qp = 0;
  deque<int> fix;
  while(ok){
    while(qp < Q.size() && Q[qp][0] == t){
      if(Q[qp][1] >= a.size()){
        ans[Q[qp][2]] = fix[Q[qp][1] - a.size()];
      }else ans[Q[qp][2]] = a[Q[qp][1]];
      qp++;
    }
    ok = 0;
    vector<int> b;
    int p2 = n/2;
    for(int i = 0; i < n/2; ++i){
      while(p2 < a.size() && a[p2] < a[i]) b.pb(a[p2++]);
      b.pb(a[i]);
    }
    for(int i = a.size()-1; i >= p2; --i) fix.push_front(a[i]);
    // for(auto k: b) cout << k << ' ';
    // for(auto k: fix) cout << k << ' ';
    // en;
    a = b;
    if(p2 > n/2) ok = 1;
    ++t;
  }
  while(qp < Q.size()){
    if(Q[qp][1] >= a.size()){
      ans[Q[qp][2]] = fix[Q[qp][1] - a.size()];
    }else ans[Q[qp][2]] = a[Q[qp][1]];
    qp++;
  }

  for(int i = 0; i < q; ++i) cout << ans[i] << '\n';
}


int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tt = 1, aa;
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  while(tt--){
    solve();
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  return 0;
} 

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:28:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     while(qp < Q.size() && Q[qp][0] == t){
      |           ~~~^~~~~~~~~~
Main.cpp:29:19: warning: comparison of integer expressions of different signedness: 'std::array<int, 3>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |       if(Q[qp][1] >= a.size()){
Main.cpp:38:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |       while(p2 < a.size() && a[p2] < a[i]) b.pb(a[p2++]);
      |             ~~~^~~~~~~~~~
Main.cpp:49:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   while(qp < Q.size()){
      |         ~~~^~~~~~~~~~
Main.cpp:50:17: warning: comparison of integer expressions of different signedness: 'std::array<int, 3>::value_type' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     if(Q[qp][1] >= a.size()){
Main.cpp: In function 'int main()':
Main.cpp:62:15: warning: unused variable 'aa' [-Wunused-variable]
   62 |   int tt = 1, aa;
      |               ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 28108 KB Output is correct
2 Correct 288 ms 27312 KB Output is correct
3 Correct 276 ms 27568 KB Output is correct
4 Correct 277 ms 25168 KB Output is correct
5 Correct 296 ms 27888 KB Output is correct
6 Correct 275 ms 25520 KB Output is correct
7 Correct 286 ms 27244 KB Output is correct
8 Correct 276 ms 25772 KB Output is correct
9 Correct 279 ms 26384 KB Output is correct
10 Correct 281 ms 26032 KB Output is correct
11 Correct 278 ms 26544 KB Output is correct
12 Correct 278 ms 25976 KB Output is correct
13 Correct 284 ms 25768 KB Output is correct
14 Correct 280 ms 27148 KB Output is correct
15 Correct 293 ms 26736 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 271 ms 25096 KB Output is correct
18 Correct 275 ms 25332 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 29492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3055 ms 7192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 28108 KB Output is correct
2 Correct 288 ms 27312 KB Output is correct
3 Correct 276 ms 27568 KB Output is correct
4 Correct 277 ms 25168 KB Output is correct
5 Correct 296 ms 27888 KB Output is correct
6 Correct 275 ms 25520 KB Output is correct
7 Correct 286 ms 27244 KB Output is correct
8 Correct 276 ms 25772 KB Output is correct
9 Correct 279 ms 26384 KB Output is correct
10 Correct 281 ms 26032 KB Output is correct
11 Correct 278 ms 26544 KB Output is correct
12 Correct 278 ms 25976 KB Output is correct
13 Correct 284 ms 25768 KB Output is correct
14 Correct 280 ms 27148 KB Output is correct
15 Correct 293 ms 26736 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 271 ms 25096 KB Output is correct
18 Correct 275 ms 25332 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Execution timed out 3064 ms 29492 KB Time limit exceeded
22 Halted 0 ms 0 KB -