Submission #229493

#TimeUsernameProblemLanguageResultExecution timeMemory
229493wilwxkChameleon's Love (JOI20_chameleon)C++14
40 / 100
21 ms420 KiB
#include <bits/stdc++.h> #include "chameleon.h" using namespace std; const int MAXN = 505; vector<int> g[MAXN], g2[MAXN]; bool marc[MAXN]; int n; void Solve(int N) { n = 2*N; for(int i = 1; i <= n; i++) { for(int j = 1; j < i; j++) { if(Query({i, j}) == 1) { g[i].push_back(j); g[j].push_back(i); // printf("%d - %d\n", i, j); } } } for(int i = 1; i <= n; i++) { if(g[i].size() == 1) { // printf("bleh %d %d\n", i, g[i][0]); if(!marc[i]) Answer(i, g[i][0]); marc[i] = marc[g[i][0]] = 1; } else { int v; if(Query({i, g[i][0], g[i][1]}) == 1) v = g[i][2]; else if(Query({i, g[i][2], g[i][1]}) == 1) v = g[i][0]; else if(Query({i, g[i][0], g[i][2]}) == 1) v = g[i][1]; g2[i].push_back(v); g2[v].push_back(i); } } for(int i = 1; i <= n; i++) { if(marc[i]) continue; int v; if(g[i][0] != g2[i][0] && g[i][0] != g2[i][1]) v = g[i][0]; else if(g[i][1] != g2[i][0] && g[i][1] != g2[i][1]) v = g[i][1]; else if(g[i][2] != g2[i][0] && g[i][2] != g2[i][1]) v = g[i][2]; marc[i] = marc[v] = 1; // printf("bleh %d %d\n", i, v); Answer(i, v); } }

Compilation message (stderr)

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:47:9: warning: 'v' may be used uninitialized in this function [-Wmaybe-uninitialized]
   Answer(i, v);
   ~~~~~~^~~~~~
#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...