Submission #725791

# Submission time Handle Problem Language Result Execution time Memory
725791 2023-04-18T04:55:20 Z Baytoro Abracadabra (CEOI22_abracadabra) C++17
0 / 100
218 ms 11936 KB
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fr first
#define sc second
#define endl '\n'
#define ll long long
#define int long long
void fopn(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const ll INF=1e18,mod=1e9+9,N=1e6+5;
int a[1005][505];
void solve(){
	int n,q;cin>>n>>q;
	for(int i=0;i<n;i++) cin>>a[i][0];
	for(int j=1;j<=n/2;j++){
		int l=0,r=n/2,cur=0;
		for(int i=0;i<n && l<n/2 && r<n;i++){
			if(a[l][j-1]<a[r][j-1])
				a[cur++][j]=a[l++][j-1];
			else
				a[cur++][j]=a[r++][j-1];
		}
		while(l<n/2)
			a[cur++][j]=a[l++][j-1];
		while(r<n)
			a[cur++][j]=a[r++][j-1];
	}
	while(q--){
		int x,y;cin>>y>>x;
		y=min(y,n/2);
		cout<<a[x-1][y]<<endl;
	}
}
main(){
	//fopn("team");
	ios;
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

Compilation message

Main.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main(){
      | ^~~~
Main.cpp: In function 'void fopn(std::string)':
Main.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 218 ms 11936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 8444 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 8488 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 218 ms 11936 KB Output isn't correct
2 Halted 0 ms 0 KB -