Submission #125346

# Submission time Handle Problem Language Result Execution time Memory
125346 2019-07-05T06:17:09 Z 구재현(#3066) Park (JOI17_park) C++14
20 / 100
67 ms 632 KB
#include "park.h"
#include <bits/stdc++.h>
using namespace std;

bool ask(int s, int e, vector<int> v){
	if(s > e) swap(s, e);
	int Place[1400] = {};
	v.push_back(s); v.push_back(e);
	for(auto &i : v) Place[i] = 1;
	return Ask(s, e, Place);
}

void dfs(vector<int> v){
	if(v.size() == 2){
		if(v[0] > v[1]) swap(v[0], v[1]);
		Answer(v[0], v[1]);
		return;
	}
	random_shuffle(v.begin() + 1, v.end() - 1);
	int s = v[0];
	int m = v[v.size() / 2];
	int e = v.back();
	vector<int> nxt;
	vector<int> ingyeo;
	for(auto &i : v){
		if(i == s || i == e || i == m) continue;
		nxt.push_back(i);
	}
	for(auto &i : v){
		if(i == s || i == e || i == m) continue;
		nxt.erase(find(nxt.begin(), nxt.end(), i));
		if(ask(s, m, nxt) == 0){
			nxt.push_back(i);
		}
		else{
			ingyeo.push_back(i);
		}
	}
	nxt.insert(nxt.begin(), s);
	nxt.push_back(m);
	ingyeo.insert(ingyeo.begin(), m);
	ingyeo.push_back(e);
	dfs(nxt);
	dfs(ingyeo);
}

void Detect(int T, int N) {
	srand(69696969);
	if(T == 1){
		for(int i=0; i<N; i++){
			for(int j=0; j<i; j++){
				if(ask(i, j, {})) Answer(j, i);
			}
		}
		return;
	}
	if(T == 2){
		vector<int> v(N);
		iota(v.begin(), v.end(), 0);
		dfs(v);
		return;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 14 ms 376 KB Output is correct
3 Correct 16 ms 376 KB Output is correct
4 Correct 16 ms 380 KB Output is correct
5 Correct 16 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 632 KB Output is correct
2 Correct 65 ms 572 KB Output is correct
3 Correct 60 ms 508 KB Output is correct
4 Correct 65 ms 584 KB Output is correct
5 Correct 63 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 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 3 ms 376 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -