Submission #697182

#TimeUsernameProblemLanguageResultExecution timeMemory
697182amunduzbaevPark (JOI17_park)C++17
10 / 100
249 ms904 KiB
#include "park.h" #include "bits/stdc++.h" using namespace std; #ifndef EVAL #include "grader.cpp" #endif mt19937 rng(chrono :: steady_clock :: now().time_since_epoch().count()); #define rnd(l, r) uniform_int_distribution<int>(l, r)(rng) static int used[1400]; void Detect(int t, int n){ auto ask = [&](int a, int b){ if(a > b) swap(a, b); int ans = Ask(a, b, used); return ans; }; auto Ans = [&](int i, int j){ if(i > j) swap(i, j); Answer(i, j); }; function<void(int, int, vector<int>)> dfs = [&](int l, int r, vector<int> tot){ //~ cout<<l<<" "; //~ for(auto x : tot) cout<<x<<" "; //~ cout<<r<<" "; //~ cout<<"\n"; if(tot.empty()){ Ans(l, r); return; } shuffle(tot.begin(), tot.end(), rng); int v = tot[rnd(0, (int)tot.size() - 1)]; vector<int> L, R; used[l] = used[r] = 1; for(auto x : tot) used[x] = 1; for(auto x : tot){ if(x == v) continue; used[x] = 0; if(ask(l, v)){ R.push_back(x); } else { used[x] = 1; L.push_back(x); } } for(auto x : L) used[x] = 0; used[l] = used[r] = used[v] = 0; dfs(l, v, L); dfs(v, r, R); }; vector<int> tot(n - 2); iota(tot.begin(), tot.end(), 1); dfs(0, n - 1, tot); } /* 1 7 6 0 4 4 3 3 1 1 2 2 5 5 6 1 6 7 0 1 0 3 1 2 1 4 2 4 2 5 3 4 */
#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...