Submission #125380

# Submission time Handle Problem Language Result Execution time Memory
125380 2019-07-05T07:12:53 Z 구재현(#3066) Park (JOI17_park) C++14
10 / 100
854 ms 1232 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() == 1) return;
	random_shuffle(v.begin(), v.end());
	int r = v[0];
	vector<int> adj;
	int j = -1;
	for(auto &i : v){
		if(i == r) continue;
		if(ask(i, r, {})){		
			j = i;
			break;
		}
	}
	vector<int> noj = v;
	noj.erase(find(noj.begin(), noj.end(), j));
	vector<int> ls, rs;
	for(auto &i : v){
		if(i == r || i == j) continue;
		if(ask(r, i, noj) == 1) ls.push_back(i);
		else rs.push_back(i);
	}
	Answer(min(r, j), max(r, j));
	ls.push_back(r);
	rs.push_back(j);
	dfs(ls);
	dfs(rs);
}

void dfs(int r, vector<int> v, int d){
	if(v.size() == 1) return;
	vector<int> adj;
	int j = -1;
	for(auto &i : v){
		if(i == r) continue;
		if(ask(i, r, {})){
			j = i;
			break;
		}
	}
	vector<int> noj = v;
	noj.erase(find(noj.begin(), noj.end(), j));
	vector<int> ls, rs;
	for(auto &i : v){
		if(i == r || i == j) continue;
		if(ask(r, i, noj) == 1) ls.push_back(i);
		else rs.push_back(i);
	}
	Answer(min(r, j), max(r, j));
	ls.push_back(r);
	rs.push_back(j);
	if(d < 5) dfs(r, ls, d + 1);
	else dfs(ls);
	if(d < 5) dfs(j, rs, d + 1);
	else dfs(rs);
}

void Detect(int T, int N) {
	srand(69696969);
	vector<int> v(N);
	iota(v.begin(), v.end(), 0);
	dfs(0, v, 0);
}
# 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 Correct 228 ms 876 KB Output is correct
2 Correct 114 ms 632 KB Output is correct
3 Correct 112 ms 708 KB Output is correct
4 Correct 242 ms 760 KB Output is correct
5 Correct 266 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 284 ms 872 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 279 ms 952 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 854 ms 1232 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -