Submission #566658

#TimeUsernameProblemLanguageResultExecution timeMemory
566658two_sidesLibrary (JOI18_library)C++17
0 / 100
38 ms208 KiB
#include <bits/stdc++.h> #include "library.h" namespace { using namespace std; const int N = 1005; int nxt[N][2]; void add_edge(int i, int j) { if (nxt[i][0]) nxt[i][1] = j; else nxt[i][0] = j; if (nxt[j][0]) nxt[j][1] = i; else nxt[j][0] = i; } } void Solve(int n) { for (int i = 1; i <= n; i++) { vector<int> p; if (nxt[i][1]) continue; for (int j = 1; j <= n; j++) if (j != i && j != nxt[i][0]) p.push_back(j); int lo = 0, hi = p.size(); while (lo < hi) { int mi = (lo + hi) / 2; vector<int> q(n); for (int j = 0; j <= mi; j++) q[p[j] - 1] = 1; int tmp = Query(q); q[i - 1] = 1; if (Query(q) > tmp) lo = mi + 1; else hi = mi; } if (hi < p.size()) add_edge(i, p[hi]); } vector<int> ans(1, 1); while (nxt[ans[0]][1]) ans[0]++; for (int i = 0; i + 1 < n; i++) { if (i == 0 || nxt[ans[i]][0] != ans[i - 1]) ans.push_back(nxt[ans[i]][0]); else ans.push_back(nxt[ans[i]][1]); } Answer(ans); }

Compilation message (stderr)

library.cpp: In function 'void Solve(int)':
library.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         if (hi < p.size()) add_edge(i, p[hi]);
      |             ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...