Submission #865552

#TimeUsernameProblemLanguageResultExecution timeMemory
865552mychecksedadAbracadabra (CEOI22_abracadabra)C++17
10 / 100
3064 ms29492 KiB
/* 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 (stderr)

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;
      |               ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...