답안 #791340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
791340 2023-07-24T02:46:20 Z jamezzz Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
252 ms 131072 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;

#define maxn 520

#define pb push_back
#define sz(x) ((int)x.size())
typedef pair<int,int> ii;

int mark[maxn],take[maxn];
vector<int> AL[maxn];

void dfs(int u,int p,vector<int> &s,int &t){
	if(mark[u])s.pb(u);
	else if(t>0)s.pb(u),--t;
	else return;
	for(int v:AL[u]){
		if(v==p)continue;
		dfs(v,u,s,t);
	}
}

int findEgg(int N,vector<ii> bridges){
	memset(mark,0,sizeof mark);
    for(auto[u,v]:bridges){
		AL[u].pb(v);
		AL[v].pb(u);
	}
	while(true){
		int rem=0;
		for(int i=1;i<=N;++i){
			if(!mark[i])++rem;
		}
		if(rem==1)break;
		rem/=2;
		vector<int> v;
		dfs(1,-1,v,rem);
		int res=query(v);
		for(int i:v)take[i]=1;
		for(int i=1;i<=N;++i){
			if(res==0&&take[i]==1)mark[i]=1;
			else if(res==1&&take[i]==0)mark[i]=1;
		}
		for(int i:v)take[i]=0;
	}
	for(int i=1;i<=N;++i){
		if(!mark[i])return i;
	}
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 252 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -