제출 #448100

#제출 시각아이디문제언어결과실행 시간메모리
448100jhnah917카멜레온의 사랑 (JOI20_chameleon)C++14
40 / 100
30 ms1328 KiB
#include "chameleon.h" #include <bits/stdc++.h> using namespace std; namespace { int N, Match[1010]; bool Love[1010][1010]; vector<int> G[1010]; } // namespace bool HasEdge(int u, int v){ return Query({ u, v }) == 1; } int Like(int v){ int a = G[v][0], b = G[v][1], c = G[v][2]; if(Query({ v, b, c }) == 1) return a; if(Query({ v, a, c }) == 1) return b; return c; } void Init(){ memset(Match, -1, sizeof Match); memset(Love, 0, sizeof Love); for(int i=0; i<1010; i++) G[i].clear(); } void Solve(int n){ N = n + n; Init(); for(int i=1; i<=N; i++){ for(int j=1; j<i; j++){ if(HasEdge(i, j)) G[i].push_back(j), G[j].push_back(i); } } for(int i=1; i<=N; i++){ if(G[i].size() == 1){ Match[i] = G[i][0]; Match[G[i][0]] = i; continue; } auto j = Like(i); Love[i][j] = Love[j][i] = true; } for(int i=1; i<=N; i++){ if(Match[i] != -1) continue; for(auto j : G[i]) if(!Love[i][j]) Match[i] = j; } for(int i=1; i<=N; i++) if(i < Match[i]) Answer(i, Match[i]); }
#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...