Submission #160049

#TimeUsernameProblemLanguageResultExecution timeMemory
160049combi1k1Library (JOI18_library)C++14
0 / 100
683 ms608 KiB
#include<bits/stdc++.h> #include "library.h" using namespace std; vector<int> ASK; /*int Query(vector<int> v) { for(int x : v) cout << x << ' '; cout << '\n'; int x; cin >> x; return x; } int Answer(vector<int> v) { for(int x : v) cout << x << ' '; }*/ int ask(vector<int> v) { if (v.size() == 1) return 1; for(int &x : ASK) x = 0; for(int &x : v) ASK[x - 1] = 1; return Query(ASK); } int Connected(int u,vector<int> v) { int a = ask(v); v.push_back(u); int b = ask(v); return a >= b; } vector<int> g[1001]; void Solve(int n) { if (n == 1) { Answer({1}); return; } if (n == 2) { Answer({1,2}); return; } ASK.resize(n); for(int i = 1 ; i <= n ; ++i) { vector<int> v; int x = i; int y = 0; if (g[i].size() == 1) y = g[i][0]; if (g[i].size() == 2) continue; for(int j = 1 ; j <= n ; ++j) if (j != x && j != y) v.push_back(j); int l = 0; int r = v.size(); for(; l < r ;) { int m = (l + r) / 2; if (Connected(i,vector<int>(v.begin(),v.begin() + m + 1))) r = m; else l = m + 1; } if (l < v.size()) { x = v[l]; //cout << x << " sieu to khong lo\n"; g[i].push_back(x); g[x].push_back(i); } } vector<int> res; for(int i = 1 ; i <= n ; ++i) if (g[i].size() == 1) { int x = i; for(int j = 0 ; j < n ; ++j) for(int u : g[x]) if (res.empty() || u != res.back()) { res.push_back(x); x = u; break; } res.push_back(x); assert(res.size() <= n); Answer(res); return; } } /*int main() { int n; cin >> n; Solve(n); }*/

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:59:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (l < v.size())   {
             ~~^~~~~~~~~~
In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from library.cpp:1:
library.cpp:76:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         assert(res.size() <= n);
                ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...