# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
271962 | erkam | Easter Eggs (info1cup17_eastereggs) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
#include<set>
#include<map>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long lo;
string s;
// int query(vector<int> hehe){
// }
int findEgg(int n,vector<pair<int,int> > bridges){
vector<int>v[n+5];
bool h[n+5]={0};
for(lo i=0;i<n;i++){
v[bridges[i].st].pb(bridges[i].nd);
v[bridges[i].nd].pb(bridges[i].st);
}
int N=n;
while(true){
if(N==1){
for(lo i=1;i<=n;i++){
if(h[i]==0) return i;
}
}
queue<int>q;
map<int,bool>sorgu;
q.push(1);
int say=0;
while(say<N/2){
int x=q.front();
q.pop();
sorgu[x]=1;
if(h[x]==0)say++;
for(int i=0;i<v[x].size();i++){
if(sorgu.count(v[x][i])==0)q.push(v[x][i]);
}
}
vector<int>sor;
for(int i=1;i<=n;i++){
if(sorgu.count(i))sor.pb(i);
}
int x=query(sor);
for(int i=1;i<=n;i++){
if(sorgu.count(i)!=x)h[i]=1;
}
if(x==0) N-=say;
else N=say;
}
}
// int main(){
// }