Submission #126266

#TimeUsernameProblemLanguageResultExecution timeMemory
126266briansuPark (JOI17_park)C++14
10 / 100
128 ms504 KiB
#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);*/ n = N; REP(i, N)REP(j, i)if(ask_edge(i, j))Add(i, j); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...