Submission #250391

# Submission time Handle Problem Language Result Execution time Memory
250391 2020-07-17T16:35:28 Z dvdg6566 Sob (COCI19_sob) C++14
0 / 110
2 ms 768 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end() 
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN=100001;
const ll MAXK=1000001;
const ll INF = 1e9;
const ll MOD = 1e9+7;

int N,M,a,b,c;
int done[MAXN];
vi A;
vi B;
vi aX;
vi bX;

void doo(){
	while(1){
		aX.clear();bX.clear();
		N=SZ(A);
		for(int i=0;i<N;++i)done[i]=0;
		int l=0;

		int k=N-1;while(k){++l;k=(k>>1);}
		--l;

		for(int i=0;i<N;++i){
			int x=A[i];
			if(x%(1<<(l+1))>=(1<<l))aX.pb(x);
		}

		for(int i=0;i<N;++i){
			int x=B[i];
			int k=(x%(1<<l));
			int t=(x%(1<<(l+1)))/(1<<l);
			if(t)continue;
			done[k]=x;
		}

		for(int i=0;i<N;++i){
			int x=B[i];
			int k=(x%(1<<l));
			int t=(x%(1<<(l+1)))/(1<<l);
			if(!t)continue;
			if(done[k]){bX.pb(x);continue;}
			done[k]=x;
		}
		// cerr<<"H ";for(auto i:bX)cout<<i<<' ';cout<<'\n';
		for(int i=0;i<(1<<l);++i)cout<<A[i]<<' '<<done[i]<<'\n';
		if(SZ(aX)==2){
			if(bX[1]%2==0)swap(bX[0],bX[1]);
			if(aX[1]%2==0)swap(aX[0],aX[1]);
			cout<<aX[0]<<' '<<bX[0]<<'\n';
			cout<<aX[1]<<' '<<bX[1]<<'\n';
			return;
		}
		swap(A,aX);
		swap(B,bX);
	}
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>N>>M;
	for(int i=0;i<N;++i){
		A.pb(i);B.pb(M+i);
	}
	doo();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Runtime error 1 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Runtime error 1 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Runtime error 1 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -