Submission #110951

#TimeUsernameProblemLanguageResultExecution timeMemory
110951JatanaLibrary (JOI18_library)C++17
100 / 100
501 ms456 KiB
#include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <set> #include "library.h" #define cout if (0) cout using namespace std; #define pb push_back #define len(v) ((int)v.size()) int N; vector<int> go(int x, set<int> forb) { cout << "RUNNING" << endl; vector<int> p{x}; vector<int> other; for (int i = 0; i < N; i++) { if (i != x && !forb.count(i)) other.pb(i); } while (!other.empty()) { int l = 0; int r = len(other); while (r - l > 1) { int m = (l + r) / 2; vector<int> Q(N, 0); for (int j = l; j < m; j++) { Q[other[j]] = 1; cout << other[j] + 1 << " "; } cout << endl; int A = Query(Q); Q[x] = 1; int B = Query(Q); if (B <= A) { cout << "GOOOD" << endl; r = m; } else { cout << "BAD" << endl; l = m; } } cout << other[l] << endl; { vector<int> Q(N, 0); Q[other[l]] = 1; int A = Query(Q); Q[x] = 1; int B = Query(Q); if (B > A) return p; } p.pb(other[l]); other.erase(other.begin() + l); x = p.back(); } return p; } void Solve(int _N) { N = _N; { vector<int> p = go(0, set<int>()); if (len(p) == N) { for (int &x : p) x++; Answer(p); return; } cout << "p[1]" << p[1] + 1 << endl; vector<int> q = go(0, set<int>(p.begin() + 1, p.end())); reverse(q.begin(), q.end()); q.pop_back(); // reverse(p.begin(), p.end()); for (int x : p) { q.pb(x); } swap(p, q); for (int &x : p) x++; for (int x : p) { cout << x << " "; } cout << endl; Answer(p); return; } // vector<int> M(N); // for(int i = 0; i < N; i++) { // M[i] = 1; // } // int A = Query(M); // vector<int> res(N); // for(int i = 0; i < N; i++) { // res[i] = i + 1; // } // Answer(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...