Submission #979680

#TimeUsernameProblemLanguageResultExecution timeMemory
979680PanndaChameleon's Love (JOI20_chameleon)C++14
4 / 100
25 ms544 KiB
#include "chameleon.h" #include <bits/stdc++.h> using namespace std; void Solve(int n) { auto query = [&](vector<int> p) -> int { for (int &i : p) i++; return Query(p); }; auto answer = [&](int i, int j) -> void { Answer(i + 1, j + 1); }; auto sum = [&](vector<int> a, vector<int> b) -> vector<int> { a.insert(a.end(), b.begin(), b.end()); return a; }; vector<vector<int>> adj(2 * n); auto work = [&](auto self, vector<int> p) -> void { vector<int> p0, p1; for (int u : p) { if (query(sum(p0, {u})) == p0.size() + 1) { p0.push_back(u); } else { p1.push_back(u); } } swap(p0, p1); for (int u : p0) { auto dfs = [&](auto self, int l, int r) -> void { if (query(sum(vector<int>(p1.begin() + l, p1.begin() + r), {u})) == r - l + 1) return; if (l + 1 == r) { adj[u].push_back(p1[l]); adj[p1[l]].push_back(u); } else { int m = (l + r) >> 1; self(self, l, m); self(self, m, r); } }; dfs(dfs, 0, n); } if (!p0.empty()) self(self, p0); }; work(work, [&]() -> vector<int> { vector<int> p(2 * n); iota(p.begin(), p.end(), 0); return p; }()); for (int u = 0; u < 2 * n; u++) { for (int i = 0; i < 3 && adj[u].size() == 3; i++) { for (int j = i + 1; j < 3 && adj[u].size() == 3; j++) { if (query({u, adj[u][i], adj[u][j]}) == 1) { adj[u] = {adj[u][i], adj[u][j]}; } } } } for (int u = 0; u < 2 * n; u++) { for (int v : adj[u]) { if (find(adj[v].begin(), adj[v].end(), u) != adj[v].end()) { if (u < v) answer(u, v); } } } }

Compilation message (stderr)

chameleon.cpp: In instantiation of 'Solve(int)::<lambda(auto:1, std::vector<int>)> [with auto:1 = Solve(int)::<lambda(auto:1, std::vector<int>)>]':
chameleon.cpp:46:103:   required from here
chameleon.cpp:23:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |             if (query(sum(p0, {u})) == p0.size() + 1) {
      |                 ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...