답안 #960344

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960344 2024-04-10T09:35:28 Z firewater Abracadabra (CEOI22_abracadabra) C++14
0 / 100
3000 ms 16748 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 j=1;j<=n;++j){
            if((r>n)||(a[l]<a[r]&&l<=n/2))b[j]=a[l++];
            else b[j]=a[r++];
        }
        for(int j=1;j<=n;++j)
            a[j]=b[j];
    }
    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);
      |         ~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 156 ms 16748 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3084 ms 8324 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3026 ms 7504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 156 ms 16748 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -