Submission #160042

#TimeUsernameProblemLanguageResultExecution timeMemory
160042combi1k1Library (JOI18_library)C++14
0 / 100
2 ms376 KiB
#include<bits/stdc++.h> #include "library.h" using namespace std; int ask(vector<int> v) { return v.size() == 1 ? 1 : Query(v); } 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) { for(int i = 1 ; i <= n ; ++i) { vector<int> v; int x = i; int y = 0; if (g[i].size()) y = g[i][0]; 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() + l,v.begin() + m + 1))) r = m; else l = m + 1; } if (l < v.size()) { x = v[l]; 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; res.push_back(0); for(int j = 0 ; j < n ; ++j) for(int u : g[x]) if (u != res.back()) { res.push_back(x); x = u; break; } res.push_back(x); res.erase(res.begin()); Answer(res); break; } }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:36:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (l < v.size())   {
             ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...