답안 #126263

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126263 2019-07-07T10:45:10 Z briansu Park (JOI17_park) C++14
0 / 100
2 ms 420 KB
#include "park.h"

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
#define REP(i, n) for(int i = 0;i < n;i ++)
#define REP1(i, n) for(int i = 1;i <= n;i ++)
#define FILL(i, n) memset(i, n, sizeof(i))
#define X first
#define Y second
#define pb push_back
#define SZ(_a) ((int)(_a).size())
#define ALL(_a) (_a).begin(), (_a).end()
#ifdef brian
template<typename T>void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...t>void _do(T &&x, t &&...X){cerr<<x<<", ";_do(X...);}
#define debug(...) {\
	fprintf(stderr, "%s - %d (%s) = ", __PRETTY_FUNCTION__, __LINE__, #__VA_ARGS__);\
	_do(__VA_ARGS__);\
}
#define IOS()
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define debug(...)
#define endl '\n'
#endif

const ll MAXn = 2e3 + 5;
const ll INF = ll(1e17);
const ll MOD = 1000000007;

static void Add(ll a, ll b)
{
	if(a > b)swap(a, b);
	debug(a, b);
	Answer(a, b);
}

static mt19937 rng;
static ll n;

static bool ask_edge(ll a,ll b)
{
	int tmp[n];
	REP(i, n)tmp[i] = (i == a || i == b);
	if(a > b)swap(a, b);
	return Ask(a, b, tmp);
}

static bool ask_split(ll a,ll b,ll c)// does a split path between b and c
{
	int tmp[n];
	REP(i, n)tmp[i] = (i != a);
	if(b > c)swap(c, b);
	return !Ask(b, c, tmp);
}

static void go(vector<ll> v)
{
	if(SZ(v) <= 1)return;
	random_shuffle(ALL(v));
	ll t = v[0];
	ll p;
	for(int i = 1;i < SZ(v);i ++)if(ask_edge(v[i], t))
	{
		p = v[i];
		break;
	}
	Add(t, p);
	vector<ll> a, b;
	a.pb(p), b.pb(t);
	for(int i = 1;i < SZ(v);i ++)if(v[i] != p)
	{
		if(ask_split(p, t, v[i]))a.pb(v[i]);
		else b.pb(v[i]);
	}
	go(a);
	go(b);
}

void Detect(int T, int N) {
	/*rng = mt19937(chrono::system_clock::now().time_since_epoch().count());
	srand(chrono::system_clock::now().time_since_epoch().count());
	n = N;
	vector<ll> v;
	REP(i, n)v.pb(i);
	go(v);*/
	REP(i, n)REP(j, i)if(ask_edge(i, j))Add(i, j);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 420 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -