Submission #963689

#TimeUsernameProblemLanguageResultExecution timeMemory
963689yellowtoadLibrary (JOI18_library)C++17
100 / 100
198 ms696 KiB
#include <cstdio> #include <vector> #include <iostream> #include "library.h" using namespace std; void Solve(int n) { int x, y; vector<int> b(n,1), res, tmp, tmmp; if (n == 1) { Answer({1}); return; } for (int i = 1; i <= n; i++) { b[i-1] = 0; if (Query(b) == 1) { res.push_back(i); for (int j = 1; j <= n; j++) if (j != i) tmp.push_back(j); break; } b[i-1] = 1; } for (int i = 2; i <= n; i++) { int l = 0, r = tmp.size()-1; while (l != r) { int mid = (l+r)/2; for (int j = 0; j < n; j++) b[j] = 0; for (int j = 0; j < res.size(); j++) b[res[j]-1] = 1; for (int j = 0; j <= mid; j++) b[tmp[j]-1] = 1; x = Query(b); b[res.back()-1] = 0; y = Query(b); if (i == 2) { if (x == y) r = mid; else l = mid+1; } else { if (y > x) r = mid; else l = mid+1; } } res.push_back(tmp[l]); tmmp.clear(); for (int j = 0; j < tmp.size(); j++) if (j != l) tmmp.push_back(tmp[j]); tmp = tmmp; } Answer(res); }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:29:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |    for (int j = 0; j < res.size(); j++) b[res[j]-1] = 1;
      |                    ~~^~~~~~~~~~~~
library.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for (int j = 0; j < tmp.size(); j++) if (j != l) tmmp.push_back(tmp[j]);
      |                   ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...