답안 #158864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
158864 2019-10-19T08:33:19 Z username Minerals (JOI19_minerals) C++14
0 / 100
248 ms 262148 KB
#include "minerals.h"
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define pb push_back
// #define __debug
#ifdef __debug
	#define pr(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {rep(zy,s,t)pr(a[zy]<<' ');pr(endl);}
#else
	#define pr(...) (void)0
	#define ar(...) (void)0
#endif
//
int ls=0,ll=0;
vector<int>v[2];

int qr(int x){
	int t=Query(x+1);
	swap(t,ls);
	return ls==t;
}

void sol(int l,int r,vector<int>&vec){
	if(l+1==r)Answer(v[0][l]+1,vec[0]+1);
	else{
		double ratio=0.5;
		int mid=l>ll?(2*l+r)/3:(l+r)/2;
		vector<int>vv[2];
		if(l>ll)REP(i,l,mid)qr(v[0][i]);
		else REP(i,mid,r)qr(v[0][i]);
		ll=l;
		REP(i,0,vec.size()){
			int t=vec[i];
			if(vv[1].size()==mid-l)vv[0].pb(t);
			else if(vv[0].size()==r-mid)vv[1].pb(t);
			else vv[qr(t)].pb(t);
		}
		sol(l,mid,vv[1]);
		sol(mid,r,vv[0]);
	}
	vector<int>().swap(vec);
}

void Solve(int n){
	REP(i,0,2*n)v[qr(i)].pb(i);
	random_shuffle(v[1].begin(),v[1].end());
	sol(0,n,v[1]);
}

Compilation message

minerals.cpp: In function 'void sol(int, int, std::vector<int>&)':
minerals.cpp:5:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,j,k) for(int i=(j);i<(k);++i)
                                   ^
minerals.cpp:34:3: note: in expansion of macro 'REP'
   REP(i,0,vec.size()){
   ^~~
minerals.cpp:36:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(vv[1].size()==mid-l)vv[0].pb(t);
       ~~~~~~~~~~~~^~~~~~~
minerals.cpp:37:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    else if(vv[0].size()==r-mid)vv[1].pb(t);
            ~~~~~~~~~~~~^~~~~~~
minerals.cpp:28:10: warning: unused variable 'ratio' [-Wunused-variable]
   double ratio=0.5;
          ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 222 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 248 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -