답안 #836293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836293 2023-08-24T09:49:51 Z KALARRY Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
188 ms 131072 KB
//chockolateman

#include<bits/stdc++.h>
#include "grader.h"


using namespace std;

int ans;
vector<int> adj[520];
int scores[520];
int target,temp;
vector<int> queries;


void dfs(int v,int p)
{
    temp -= scores[v];
    queries.push_back(v);
    if(temp==0)
        return;
    for(auto u : adj[v])
        if(u!=p)
            dfs(u,v);
}

int findEgg(int N,vector<pair<int,int>> bridges)
{
    for(auto e : bridges)
    {
        int a = e.first;
        int b = e.second;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i = 1 ; i <= N ; i++)
       scores[i] = 1;
    target = N;
    while(target>1)
    {
        queries.clear();
        target/=2;
        temp = target;
        dfs(1,1);
        int res = query(queries);
        if(res==0)
            for(auto u : queries)
                scores[u] = 0;
        else
        {
            for(auto u : queries)
                scores[u]++;
            for(int i = 1 ; i <= N ; i++)
            {
                if(scores[i]==1)
                    scores[i] = 0;
                if(scores[i]==2)
                    scores[i] = 1;
            }
        }
    }
    int egg = -1;
    for(int i = 1 ; i <= N ; i++)
        if(scores[i]==1)
            egg = i;
    return egg;    
}
# 결과 실행 시간 메모리 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 181 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 188 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -