Submission #960343

# Submission time Handle Problem Language Result Execution time Memory
960343 2024-04-10T09:33:22 Z firewater Abracadabra (CEOI22_abracadabra) C++14
0 / 100
3000 ms 16488 KB
#include<bits/stdc++.h>
#define ll long long
#define fs first
#define sn second
#define N 202400
using namespace std;
int n,m,x,y,z,now,sav,l,r,v[N],a[N],b[N],nx[N],sz[N],ans[N],p[N];
tuple<int,int,int>q[N];
stack<int>st;
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i){
        scanf("%d",&a[i]);
        v[a[i]]=i;
    }
    for(int i=1;i<=m;++i){
        scanf("%d%d",&x,&y);
        q[i]=tie(x,y,i);
    }
    sort(q+1,q+1+m);
    now=1;
    for(int i=0;i<=n+2;++i){
        while(now<=m&&get<0>(q[now])==i){
            tie(x,y,z)=q[now];
            ans[z]=a[y];
            now++;
        }
        l=1;
        r=n/2+1;
        for(int i=1;i<=n;++i){
            if((r>n)||(a[l]<a[r]&&l<=n/2))b[i]=a[l++];
            else b[i]=a[r++];
        }
        for(int i=1;i<=n;++i)
            a[i]=b[i];
    }
    while(now<=m){
        tie(x,y,z)=q[now];
        ans[z]=a[y];
        now++;
    }
    for(int i=1;i<=m;++i)
        printf("%d\n",ans[i]);
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
Main.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
Main.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 148 ms 16488 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3023 ms 8272 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3027 ms 7284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 148 ms 16488 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -