제출 #296359

#제출 시각아이디문제언어결과실행 시간메모리
296359BTheroPark (JOI17_park)C++17
10 / 100
873 ms1016 KiB
// chrono::system_clock::now().time_since_epoch().count() #include "park.h" #include<bits/stdc++.h> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define all(x) (x).begin(), (x).end() #define debug(x) cerr << #x << " = " << x << endl; using namespace std; typedef long long ll; typedef pair<int, int> pii; namespace { int subtask_no, n; mt19937 rnd(chrono::system_clock::now().time_since_epoch().count()); bool ask(int a, int b, vector<int> &vec) { if (a > b) { swap(a, b); } int tmp[n]; fill(tmp, tmp + n, 0); for (int x : vec) { tmp[x] = 1; } return Ask(a, b, tmp); } void report(int a, int b) { if (a > b) { swap(a, b); } Answer(a, b); } vector<int> calc(int L, int R, vector<int> S) { vector<int> ret; if (S.size() == 2) { ret.pb(L); ret.pb(R); return ret; } int m = rnd() % S.size(); while (S[m] == L || S[m] == R) { m = rnd() % S.size(); } int M = S[m]; vector<int> A, B; A.pb(L); A.pb(M); B.pb(M); B.pb(R); for (int x : S) { if (x != L && x != M && x != R) { vector<int> S2 = S; S2.erase(find(all(S2), x)); if (ask(L, M, S2)) { B.pb(x); } else { A.pb(x); } } } A = calc(L, M, A); B = calc(M, R, B); for (int x : A) { ret.pb(x); } ret.pop_back(); for (int x : B) { ret.pb(x); } return ret; } void solve() { vector<int> S; for (int i = 0; i < n; ++i) { S.pb(i); } S = calc(0, n - 1, S); for (int i = 0; i + 1 < n; ++i) { report(S[i], S[i + 1]); } } }; void Detect(int T, int N) { subtask_no = T; n = N; solve(); }
#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...