Submission #125347

# Submission time Handle Problem Language Result Execution time Memory
125347 2019-07-05T06:24:04 Z 임유진(#3061) Park (JOI17_park) C++14
0 / 100
422 ms 436 KB
#include "park.h"
#include<algorithm>

using namespace std;

static int zero[1400], one[1400];
static int N;
static bool chk[1400];

void answer(int a, int b) {
	Answer(min(a, b), max(a, b));
}

int ask(int a, int b, int place[]) {
	return Ask(min(a, b), max(a, b), place);
}

int f(int x, int y) {
	zero[x] = zero[y] = 1;
	int t = ask(x, y, zero);
	zero[x] = zero[y] = 0;
	if(t == 1) return -1;

	int s = 0, e = N - 1;
	int cnt = N - 2;
	while(cnt > 1) {
		int m = s;
		for(int i = 0; i < cnt / 2 - 1; i++) {
			while(m == x || m == y) m++;
			m++;
		}
		for(int i = s; i <= m; i++) if(i != x && i != y) one[i] = 0;
		t = ask(x, y, one);
		for(int i = s; i <= m; i++) one[i] = 1;
		if(t == 0) {
			e = m;
			cnt /= 2;
		}
		else {
			s = m + 1;
			cnt = cnt - cnt / 2;
		}
	}
	while(s == x || s == y) s++;
	return s;
}

void solve(int x, int y) {
	//printf("solve(x = %d, y = %d)\n", x, y);
	if(chk[y]) return;
	int z = f(x, y);
	//printf("z = %d\n", z);
	if(z == -1) {
		answer(x, y);
		chk[y] = true;
	}
	else {
		solve(x, z);
		solve(z, y);
	}
}

void Detect(int T, int N) {
	if(T != 3 && T != 4) return;
	::N = N;
	for(int i = 0; i < N; i++) one[i] = 1;
	for(int i = 1; i < N; i++) solve(0, i);
}

Compilation message

park.cpp: In function 'int f(int, int)':
park.cpp:24:13: warning: variable 'e' set but not used [-Wunused-but-set-variable]
  int s = 0, e = N - 1;
             ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 422 ms 436 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 209 ms 428 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -