답안 #428814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
428814 2021-06-15T14:39:05 Z kai824 Park (JOI17_park) C++17
10 / 100
17 ms 844 KB
#include "park.h"
#include<bits/stdc++.h>
using namespace std;

static int place[1400],n;

int r,r2;
vector<int> avail;

void dnc(int a,int b,bool first=false){//find edges from node a to b...
	if(a>b)swap(a,b);
	//cerr<<"DNC "<<a<<' '<<b<<'\n';
	/*if(first){
		if(b==1)Answer(a,b);
		else{
			dnc(a,a+1);
			dnc(a+1,b);
		}
		return;
	}*/
	place[a]=place[b]=1;
	if(Ask(a,b,place)==1){
		//cerr<<"Ansewr "<<a<<' '<<b<<'\n';
		Answer(a,b);
		place[a]=place[b]=0;
	}else{
		int lo=0,hi=avail.size()-1,mid;
		while(lo<hi){
			//cerr<<"check "<<lo<<' '<<hi<<":\t";
			mid=lo+((hi-lo)/2);
			for(int j=lo;j<=mid;j++){
				place[avail[j]]=1;
				//cerr<<r<<' ';
			}//cerr<<'\n';
			place[a]=place[b]=1;
			r=Ask(a,b,place);
			for(int j=lo;j<=mid;j++){
				place[avail[j]]=0;
			}
			if(r==0){//cos we need to find a node in between...
				lo=mid+1;
			}else{
				hi=mid;
			}
		}
		mid=avail[lo];
		avail.erase(avail.begin()+lo);
		//cerr<<'\n';
		place[a]=place[b]=0;
		dnc(a,mid);
		dnc(mid,b);
	}
}

void Detect(int t, int N){
	n=N;
	avail.clear();
	for(int i=1;i+1<n;i++)avail.push_back(i);
	if(t==1){
		for(int i=0;i<n;i++){
			place[i]=1;
			for(int j=i+1;j<n;j++){
				place[j]=1;
				if(Ask(i,j,place)==1)Answer(i,j);
				place[j]=0;
			}
			place[i]=0;
		}
	}else if(t==2){
		dnc(0,n-1,true);
	}
}

/*int i;
for(i = 0 ; i < 2 ; i++) Place[i] = 0;
for(i = 2 ; i < N ; i++) Place[i] = 1;
if(Ask(3, 5, Place) != 1) return;
Answer(2, 4);
Answer(2, 5);
Answer(3, 4);
Place[0] = 1;
Place[3] = 0;
Place[5] = 0;
if(Ask(0, 4, Place) != 0) return;
Answer(0, 1);
Answer(0, 3);
Answer(1, 4);
Answer(1, 2);*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 5 ms 204 KB Output is correct
3 Correct 5 ms 332 KB Output is correct
4 Correct 8 ms 204 KB Output is correct
5 Correct 9 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 17 ms 844 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -