Submission #126175

# Submission time Handle Problem Language Result Execution time Memory
126175 2019-07-07T08:03:46 Z briansu Park (JOI17_park) C++14
0 / 100
365 ms 872 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;
	ll t = v[rng() % SZ(v)];
	debug(t);
	for(ll x:v)debug(x);
	vector<ll> sp;
	for(ll k:v)if(k != t && ask_edge(t, k))sp.pb(k);
	for(ll k:sp)debug(k);
	for(ll k:sp)
	{
		Add(k, t);
		vector<ll> tmp;
		tmp.pb(k);
		for(ll x:v)if(x != k && x != t && ask_split(k, x, t))tmp.pb(x);
		go(tmp);
	}
}

void Detect(int T, int N) {
	rng = mt19937(chrono::system_clock::now().time_since_epoch().count());
	n = N;
	vector<ll> v;
	REP(i, n)v.pb(i);
	go(v);
}

Compilation message

park.cpp: In function 'void go(std::vector<long long int>)':
park.cpp:64:9: warning: unused variable 'x' [-Wunused-variable]
  for(ll x:v)debug(x);
         ^
park.cpp:67:9: warning: unused variable 'k' [-Wunused-variable]
  for(ll k:sp)debug(k);
         ^
# 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 365 ms 652 KB Output is correct
2 Incorrect 309 ms 632 KB Wrong Answer[5]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 328 ms 872 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 196 ms 768 KB Wrong Answer[5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 504 KB Wrong Answer[6]
2 Halted 0 ms 0 KB -