Submission #347310

#TimeUsernameProblemLanguageResultExecution timeMemory
347310maomao90Library (JOI18_library)C++14
0 / 100
1 ms364 KiB
#include "library.h" #include <bits/stdc++.h> using namespace std; #define REP(i, j, k) for (int i = j; i < k; i++) #define pb push_back void Solve(int n) { vector<int> q(n, 1), res(n, -1), done(n, 0); int end = -1; REP (i, 0, n) { q[i] = 0; if (Query(q) == 1) { end = i; break; } q[i] = 1; } printf("%d\n", end); res[0] = end; done[end] = 1; REP (i, 1, n) { vector<int> useful; REP (j, 0, n) if (!done[j]) useful.pb(j); int lo = 0, hi = useful.size() - 1, mid; while (lo < hi) { mid = lo + hi + 1 >> 1; REP (j, 0, n) q[j] = 0; REP (j, 0, mid) q[useful[j]] = 1; q[res[i - 1]] = 1; int with = Query(q); q[res[i - 1]] = 0; int without = Query(q); if (with == without) { hi = mid - 1; } else { lo = mid; } } res[i] = useful[hi]; done[useful[hi]] = 1; } REP (i, 0, n) res[i]++; Answer(res); }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:27:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |    mid = lo + hi + 1 >> 1;
      |          ~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...