답안 #61407

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61407 2018-07-25T19:44:45 Z khohko CEOI16_icc (CEOI16_icc) C++17
0 / 100
51 ms 47512 KB
#include "icc.h"
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define fr first
#define sc second
#define pb push_back
#define ARRS ((ll)(2e6+100))
#define MAX ((ll)(2e9+100))

ll a[ARRS];
ll b[ARRS];
ll ca,cb;

ll pr[ARRS];
ll f[ARRS];
vector<ll> v[ARRS];

ll par(ll x){
	if(x==pr[x])return x;
	else return pr[x]=par(pr[x]);
}

void join(ll x,ll y){
	x=par(x);
	y=par(y);
	if(x==y)return;
	pr[y]=x;
}

//void setRoad(ll a,ll b){
//	cout<<"------"<<endl;
//	cout<<"PAS:"<<a<<" "<<b<<endl;
//	cout<<endl;
//}
//ll query(ll n,ll m,ll *a,ll *b){
//	cout<<n<<endl;
//	for(int i=0; i<n; i++)cout<<a[i]<<" \n"[i==n-1];
//	cout<<m<<endl;
//	for(int i=0; i<m; i++)cout<<b[i]<<" \n"[i==m-1];
//	cout<<"????\n";
//	ll k;
//	cin>>k;
//	cout<<endl;
//	return k;
//}



void run(int n){
	for(int i=0; i<n; i++){
		pr[i]=i;
		v[i].pb(i);
	}

	vector<ll> va,vb;
	for(int i=0; i<n-1; i++){
		do{
			for(int i=0; i<n; i++)
				f[i]=0;
			ca=cb=0;
			for(int i=0; i<n; i++){
				if(!f[par(i)])
					f[par(i)]=rand()%2+1;
				if(f[par(i)]==1)a[ca++]=i;
				else b[cb++]=i;
			}
		}
		while(!query(ca,cb,a,b));

		va.clear();
		vb.clear();
		for(int i=0; i<n; i++){
			//if(i==par(i)){
			if(f[par(i)]==1)va.pb(i);
			else vb.pb(i);
			//}
		}
		ll l=1,r=va.size();
		while(l<r){
			ll m=l+r>>1;
			ca=0;
			for(int i=0; i<m; i++){
				//for(auto k:v[va[i]])
				a[ca++]=va[i];
			}
			if(query(ca,cb,a,b))
				r=m;
			else l=m+1;
		}
		ca=1;
		ll x=va[l-1];
		a[0]=x;
		l=1,r=vb.size();
		while(l<r){
			ll m=l+r>>1;
			cb=0;
			for(int i=0; i<m; i++){
				//for(auto k:v[vb[i]])
				b[cb++]=vb[i];
			}
			if(query(ca,cb,a,b))
				r=m;
			else l=m+1;
		}
		ll y=vb[l-1];
		setRoad(x,y);
		join(x,y);
	}

}
//
//int main(){
//	run(5);
//
//
//}




Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:81:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    ll m=l+r>>1;
         ~^~
icc.cpp:96:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    ll m=l+r>>1;
         ~^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 49 ms 47352 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 47496 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 49 ms 47496 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 49 ms 47496 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 44 ms 47508 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 47512 KB Query cities not in range [1, n]
2 Halted 0 ms 0 KB -