답안 #483639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483639 2021-10-31T12:29:45 Z alexdumitru Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
284 ms 131076 KB
#include <iostream>
#include <vector>
#include <grader.h>
using namespace std;
vector<int> a[550];
vector<int> parcurgere;
int viz[550];
void dfs(int nod=1, int p=-1)
{
    parcurgere.push_back(nod);
    for(auto i:a[nod])if(i!=p)dfs(i,nod);
}
int findEgg(int N, vector<pair<int,int> > bridges)
{
    int st,r=N-1,poz=N,mi,dr,i,m=bridges.size();
    for(i=1;i<=N;i++)viz[i]=0;
    for(i=0;i<m;i++)
    {
        a[bridges[i].first].push_back(bridges[i].second);
        a[bridges[i].second].push_back(bridges[i].first);
    }
    dfs();
    st=0;
    dr=N-1;
    while(st<=dr)
    {
        mi=st+(dr-st)/2;
        if(query(vector<int>(parcurgere.begin(),parcurgere.begin()+mi+1)))
        {
            dr=mi-1;
            r=mi;
        }
        else st=mi+1;
    }
    return parcurgere[r];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:15:18: warning: unused variable 'poz' [-Wunused-variable]
   15 |     int st,r=N-1,poz=N,mi,dr,i,m=bridges.size();
      |                  ^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 284 ms 131076 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 192 ms 131076 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 208 ms 131076 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -