Submission #814095

#TimeUsernameProblemLanguageResultExecution timeMemory
814095IBoryChameleon's Love (JOI20_chameleon)C++17
40 / 100
2 ms464 KiB
#include "chameleon.h" #include <bits/stdc++.h> #define pii pair<int, int> using namespace std; const int MAX = 505; vector<int> G[MAX]; int checked[MAX]; void Solve(int N) { N <<= 1; for (int i = 1; i <= N; ++i) { for (int j = i + 1; j <= N; ++j) { vector<int> go = {i, j}; int c = Query(go); if (c == 1) { G[i].push_back(j); G[j].push_back(i); } } } vector<pii> ans; for (int i = 1; i <= N; ++i) { if (checked[i]) continue; if (G[i].size() == 1) { ans.emplace_back(i, G[i][0]); checked[i] = checked[G[i][0]] = 1; } else if (G[i].size() == 3) { for (int k = 0; k < 3; ++k) { if (checked[G[i][k]]) continue; int a = i, b = G[i][k]; vector<int> remain = G[a]; for (int n : G[b]) remain.push_back(n); int same = 0; for (int n : remain) { if (n == a || n == b) continue; vector<int> go = {a, b, n}; int c = Query(go); if (c == 1) same++; } if (same == 2) { ans.emplace_back(a, b); checked[a] = checked[b] = 1; break; } } } else exit(99); } for (auto [a, b] : ans) Answer(a, b); }
#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...