제출 #1130189

#제출 시각아이디문제언어결과실행 시간메모리
1130189Pekiban도서관 (JOI18_library)C++17
0 / 100
20 ms408 KiB
#include <bits/stdc++.h> #include "library.h" using namespace std; void Solve(int n) { int f = 0; vector<int> a(n, 1); for (int i = 0; i < n; ++i) { a[i] = 0; if (Query(a) == 1) { f = i+1; break; } a[i] = 1; } vector<int> ans = {f}; for (int i = 1; i < n; ++i) { vector<int> S(n, 1); for (auto x : ans) S[x] = 0; while (1) { vector<int> S1(n, 0), S2(n, 0); int C = 0, t = 0, sz = 0; for (int j = 0; j < n; ++j) sz += S[j]; for (int j = 0; j < n; ++j) { if (S[j]) { if (C < (sz+1)/2) S1[j] = 1, t = j+1; else { S2[j] = 1; } ++C; } } if (C == 1) { ans.push_back(t); break; } int x = Query(S1); S1[ans.back() - 1] = 1; if (Query(S1) > x) S = S2; else { S1[ans.back() - 1] = 0; S = S1; } } } Answer(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...