Submission #428788

# Submission time Handle Problem Language Result Execution time Memory
428788 2021-06-15T14:31:13 Z kai824 Park (JOI17_park) C++17
10 / 100
53 ms 704 KB
#include "park.h"
#include<bits/stdc++.h>
using namespace std;

static int place[1400],n;

int r,r2;

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);
	}
	else{
		int lo=0,hi=n-1-2,mid;
		while(lo<hi){
			//cerr<<"check "<<lo<<' '<<hi<<":\t";
			mid=lo+((hi-lo)/2);
			for(int j=lo;j<=mid;j++){
				r=j;
				if(a<=r)r++;
				if(b<=r)r++;
				place[r]=1;
				//cerr<<r<<' ';
			}//cerr<<'\n';
			place[a]=place[b]=1;
			r=Ask(a,b,place);
			for(int j=lo;j<=mid;j++){
				r2=j;
				if(a<=r2)r2++;
				if(b<=r2)r2++;
				place[r2]=0;
			}
			if(r==0){//cos we need to find a node in between...
				lo=mid+1;
			}else{
				hi=mid;
			}
		}
		if(a<=lo)lo++;
		if(b<=lo)lo++;
		//cerr<<'\n';
		dnc(a,lo);
		dnc(lo,b);
	}
	place[a]=place[b]=0;
}

void Detect(int t, int N){
	n=N;
	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);*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 7 ms 320 KB Output is correct
3 Correct 5 ms 204 KB Output is correct
4 Correct 5 ms 204 KB Output is correct
5 Correct 6 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 704 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -