Submission #1080153

#TimeUsernameProblemLanguageResultExecution timeMemory
1080153adaawfLibrary (JOI18_library)C++17
0 / 100
36 ms344 KiB
#include <iostream> #include <vector> #include "library.h" using namespace std; int dd[1005]; /*int Query(vector<int> v) { for (int w : v) cout << w << " "; cout << endl; int x; cin >> x; return x; } void Answer(vector<int> v) { for (int w : v) cout << w << " "; cout << endl; }*/ void Solve(int n) { for (int i = 0; i < n; i++) dd[i] = 0; vector<int> res; for (int i = 0; i < n; i++) { vector<int> vv; for (int j = 0; j < n; j++) { if (i == j) vv.push_back(0); else vv.push_back(1); } if (Query(vv) == 1) { res.push_back(i); break; } } for (int i = 0; i < n; i++) { if (i == res.back()) continue; vector<int> vv; for (int j = 0; j < n; j++) { if (j == i || j == res.back()) vv.push_back(1); else vv.push_back(0); } if (Query(vv) == 1) { res.push_back(i); break; } } dd[res[0]] = dd[res[1]] = 1; for (int i = 2; i < n; i++) { vector<int> v; for (int j = 0; j < n; j++) { if (dd[j] == 0) { v.push_back(j); } } int l = 0, r = v.size() - 2, g = v.size() - 1; while (l <= r) { int mid = (l + r) / 2; vector<int> vv(n, 0); for (int j = 0; j <= mid; j++) vv[v[j]] = 1; for (int j = 0; j < res.size(); j++) vv[res[j]] = 1; int h = Query(vv); vv[res.back()] = 0; int k = Query(vv); if (h != k) { g = mid; r = mid - 1; } else l = mid + 1; } res.push_back(v[g]); dd[v[g]] = 1; } for (int &w : res) w++; Answer(res); } /*int main() { Solve(5); }*/

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:56:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             for (int j = 0; j < res.size(); j++) vv[res[j]] = 1;
      |                             ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...