Submission #47843

#TimeUsernameProblemLanguageResultExecution timeMemory
47843Just_Solve_The_ProblemLibrary (JOI18_library)C++14
19 / 100
548 ms544 KiB
#include <bits/stdc++.h> //#include "grader.cpp" #include "library.h" #define pb push_back #define ok cerr << "OK\n"; using namespace std; const int NN = 1e3 + 7; bool used[NN]; void Solve(int N) { vector < int > M(N, 0); vector < int > ans, vv; if (N == 1) { ans.pb(1); Answer(ans); return ; } deque < int > dq; int n = N; int cnt = 0; M[0] = 1; dq.pb(0); used[0] = 1; for (int i = 1; i < n; i++) { M[i] = 1; int qq = Query(M); if (qq == 1) { cnt++; vv.pb(i); } M[i] = 0; } M[0] = 0; used[vv[0]] = 1; dq.push_front(vv[0]); if (cnt == 2) { dq.push_back(vv[1]); used[vv[1]] = 1; } vv.clear(); cnt++; while (cnt < n) { bool fl = 1; M[dq.back()] = 1; for (int j = 0; j < n; j++) { if (used[j]) continue; M[j] = 1; int qq = Query(M); M[j] = 0; if (qq == 1) { fl = 0; M[dq.back()] = 0; dq.pb(j); M[j] = 1; used[j] = 1; cnt++; break; } } M[dq.back()] = 0; if (fl) break; } for (int i = 0; i < n; i++) M[i] = 0; while (cnt < n) { bool fl = 1; M[dq.front()] = 1; for (int j = 0; j < n; j++) { if (used[j]) continue; M[j] = 1; int qq = Query(M); M[j] = 0; if (qq == 1) { fl = 0; M[dq.front()] = 0; dq.push_front(j); M[dq.front()] = 1; used[j] = 1; cnt++; break; } } if (fl) break; } for (int to : dq) { ans.pb(to + 1); } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...