이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> ask;
vector<int> adj[1005];
bool used[1005];
bool wrong[1005];
long long size=0;
long long cnt=0;
void dfs(long long node, long long par){
if(cnt==size/2) return;
if(used[node]==0)
{
cnt++;
}
ask.push_back(node);
for(auto i : adj[node]){
if(wrong[i]!=0||i==par) continue;
dfs(i,node);
}
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
ask.clear();
memset(used,0,sizeof(used));
memset(wrong,0,sizeof(wrong));
for(int i=1;i<=N;i++){
adj[i].clear();
}
size=N;
for(auto i:bridges)
{
adj[i.first].push_back(i.second);
adj[i.second].push_back(i.first);
}
while(true)
{
ask.clear();
if(size==1)
{
for(int i=1; i<=N; i++)
{
if(wrong[i]==0&&used[i]==0)
{
return i;
}
}
}
else
{
cnt=0;
dfs(1,1);
if(query(ask)!=0)
{
size=cnt;
bool lay[1000];
memset(lay, 0, sizeof(lay));
for(auto i:ask)
{
lay[i]=1;
}
for(int i=1; i<=N; i++)
{
if(lay[i]==0)
{
wrong[i]=true;
}
}
}
else
{
size-=cnt;
for(auto i:ask)
{
used[i]=true;
}
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |