Submission #341441

#TimeUsernameProblemLanguageResultExecution timeMemory
341441ijxjdjdLibrary (JOI18_library)C++14
100 / 100
371 ms644 KiB
#include <cstdio> #include <vector> #include "library.h" using namespace std; #include <bits/stdc++.h> vector<int> M; int query(vector<int> q) { fill(M.begin(), M.end(), 0); // for (int i : q) { // cout << i << " "; // } // cout << '\n'; for (int i : q) { M[i-1] = 1; } int res = Query(M); // cout << res << '\n'; return res; } void Solve(int N) { M.resize(N); vector<int> cur; vector<int> left(N); for(int i = 0; i < N; i++) { left[i] = i+1; } cur.push_back(*(left.end()-1)); left.pop_back(); while (left.size() > 0) { int low = 0; int high = left.size()-1; while (low < high) { int mid = (low + high)/2; vector<int> add(left.begin()+low, left.begin()+mid+1); int bef = query(add); add.insert(add.end(), cur.begin(), cur.end()); int after = query(add); if (bef+1 == after) { low = mid+1; } else { high = mid; } } cout << '\n'; vector<int> side = {cur[0], left[high]}; if (query(side) == 1) { cur.insert(cur.begin(), left[high]); } else { cur.push_back(left[high]); } left.erase(left.begin() + high); } Answer(cur); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...