Submission #266929

#TimeUsernameProblemLanguageResultExecution timeMemory
266929Toirov_SadiLibrary (JOI18_library)C++17
19 / 100
3004 ms384 KiB
#include<bits/stdc++.h> #include "library.h" using namespace std; void Solve(int N){ vector<int> q(N, 1); vector<int> q1(N, 0); unordered_set<int> p; for(int i = 1; i <= N; i ++) p.insert(i); vector<int> l, r; while((int)p.size() > 1){ int x = -1; int y = -1; for(auto X: p){ if(x != -1 && y != -1) break; q[X - 1] = 0; if(Query(q) == 1){ if(x == -1) x = X; else if(y == -1) y = X; } q[X - 1] = 1; } if(!l.empty()){ int z = x; q1[z - 1] = 1; q1[l.back() - 1] = 1; if(Query(q1) == 2) swap(x, y); q1[z - 1] = 0; q1[l.back() - 1] = 0; } l.push_back(x); r.push_back(y); p.erase(x); p.erase(y); q[x - 1] = 0; q[y - 1] = 0; } if(!p.empty()) l.push_back(*p.begin()); vector<int> res; for(int i = 0; i < (int)l.size(); i ++) res.push_back(l[i]); for(int i = (int)r.size() - 1; i >= 0; i --) res.push_back(r[i]); Answer(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...