Submission #960342

#TimeUsernameProblemLanguageResultExecution timeMemory
960342firewaterAbracadabra (CEOI22_abracadabra)C++14
0 / 100
3065 ms16508 KiB
#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;1;++i){ while(now<=m&&get<0>(q[now])==i){ tie(x,y,z)=q[now]; ans[z]=a[y]; now++; } if(now>m)break; 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]; } for(int i=1;i<=m;++i) printf("%d\n",ans[i]); return 0; }

Compilation message (stderr)

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