# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
67731 | 2018-08-15T09:18:23 Z | tempytemptemp | Easter Eggs (info1cup17_eastereggs) | C++14 | 0 ms | 0 KB |
#include <vector> #include <cassert> #include <algorithm> #include "grader.h" using namespace std; int findEgg(int N, vector < pair < int, int > > bridges); int query(vector < int > islands); int findEgg(int n, vector<pair<int,int>>bridges){ assert(n<=16); bool pos[n+1]; for(int i=1; i<=n; i++) pos[i]=1; for(int i=0; i<bridges.size(); i++){ if(!pos[bridges[i].first] && !pos[bridges[i].second]) continue; if(!pos[bridges[i].first]){ if(query({bridges[i].second})) return bridges[i].second; else{ pos[bridges[i].second]=0; continue; } } else if(!pos[bridges[i].second){ if(query({bridges[i].first})) return bridges[i].first; else{ pos[bridges[i].first]=0; continue; } } if(query({bridges[i].first, bridges[i].second})){ if(query({bridges[i].first})) return bridges[i].first; else return bridges[i].second; } else{ pos[bridges[i].first]=pos[bridges[i].second]=0; } } return -1; }