Submission #933778

#TimeUsernameProblemLanguageResultExecution timeMemory
933778nguyentunglamChameleon's Love (JOI20_chameleon)C++17
40 / 100
14 ms2648 KiB
#include "chameleon.h" #include <vector> #include<bits/stdc++.h> using namespace std; namespace { const int NN = 1e3 + 10; vector<int> adj[NN]; bool g[NN][NN]; int love[NN][NN]; void solve(int n) { for(int i = 1; i <= 2 * n; i++) for(int j = i + 1; j <= 2 * n; j++) { if (Query({i, j}) == 1) { adj[i].push_back(j); adj[j].push_back(i); } } int m = 4, mx = 0; for(int i = 1; i <= 2 * n; i++) { int x = -1; for(int j = 0; j < m; j++) if (!g[j][i]) { x = j; break; } assert(x >= 0); mx = max(mx, x); for(int &v : adj[i]) g[x][v] = 1; } assert(mx <= 4); // cerr << mx << endl; for(int i = 1; i <= 2 * n; i++) { assert(adj[i].size() == 1 || adj[i].size() == 3); if (adj[i].size() == 1) continue; for(int &j : adj[i]) { vector<int> tmp; tmp.push_back(i); for(int &k : adj[i]) if (k != j) tmp.push_back(k); if (Query(tmp) == 1) { love[i][j] = 1; } } } for(int i = 1; i <= 2 * n; i++) { for(int &j : adj[i]) if (i < j && love[i][j] + love[j][i] == 0) { Answer(i, j); } } } } // namespace void Solve(int n) { ::solve(n); }
#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...