# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
313033 | 2020-10-15T02:25:51 Z | alexhu | 게임 (IOI14_game) | C++14 | 0 ms | 0 KB |
/** * https://oj.uz/problem/view/IOI14_game * */ #include <bits/stdc++.h> using namespace std; vector<vector<int>>graph(1500,vector<int>(1500,0)); int N; void initialize(int n){ N=n; } int hasEdge(int u,int v){ graph[u][v]=2; graph[v][u]=2; if(dfs()){ return 0; }else{ graph[u][v]=1; graph[v][u]=1; return 1; } } bool dfs(){ list<int>q; vector<int>visited(N,0); q.push_back(0); visited[0]=1; while(!q.empty()){ int x=q.front(); q.pop_front(); for(int i=0;i<N;i++){ if(x!=i&&graph[x][i]!=2&&!visited[i]){ q.push_back(i); visited[i]=1; } } } return [&]()->bool{ for(int i=0;i<N;i++){ if(!visited[i]){ return false; } } return true; }(); }