Submission #47888

#TimeUsernameProblemLanguageResultExecution timeMemory
47888Just_Solve_The_ProblemLibrary (JOI18_library)C++14
19 / 100
2059 ms652 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 = 1e5 + 7; int used[NN]; void Solve(int N) { vector < int > M(N, 1); int n = N; vector < int > ans, v1, v2; set < int > s; for (int i = 0; i < n; i++) s.insert(i); int cnt = 0, qq; set < int > :: iterator it; while (cnt < n - 1) { it = s.begin(); vector < int > del; for (; it != s.end() && cnt < n - 1; it++) { int i = *it; M[i] = 0; qq = Query(M); M[i] = 1; if (qq == 1) { if (v1.empty()) { v1.pb(i); } else { M[v1.back()] = 1; M[i] = 0; qq = Query(M); M[v1.back()] = 0; if (qq == 1) { v2.pb(i); } else { v1.pb(i); } } used[i] = 1; del.pb(i); cnt++; M[i] = 0; } } for (int to : del) s.erase(to); if (!(cnt < n - 1)) break; it = s.end(); it--; del.clear(); for (; cnt < n - 1; it--) { int i = *it; M[i] = 0; qq = Query(M); M[i] = 1; if (qq == 1) { if (v1.empty()) { v1.pb(i); } else { M[v1.back()] = 1; M[i] = 0; qq = Query(M); M[v1.back()] = 0; if (qq == 1) { v2.pb(i); } else { v1.pb(i); } } used[i] = 1; cnt++; del.pb(i); M[i] = 0; } if (it == s.begin()) break; } for (int to : del) { s.erase(to); } } for (int i = 0; i < n; i++) { if (!used[i]) v1.pb(i); } for (int to : v1) { ans.pb(to + 1); } for (int i = (int)v2.size() - 1; i >= 0; i--) { ans.pb(v2[i] + 1); } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...