답안 #875786

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
875786 2023-11-20T13:40:07 Z Aiperiii Easter Eggs (info1cup17_eastereggs) C++14
100 / 100
11 ms 1240 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector <int> g[513];
vector <int> tin;
void dfs(int v,int p){
    tin.push_back(v);
    for(auto to : g[v]){
        if(to!=p)dfs(to,v);
    }
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(int i=1;i<=N;i++)g[i].clear();
    tin.clear();
    for(int i=0;i<bridges.size();i++){
        g[bridges[i].first].push_back(bridges[i].second);
        g[bridges[i].second].push_back(bridges[i].first);
    }
    dfs(1,-1);
    int l=0,r=N-1;
    while(l<r){
        int md=(l+r)/2;
        vector <int> check;
        for(int i=0;i<=md;i++)check.push_back(tin[i]);
        if(query(check))r=md;
        else l=md+1;
    }
    return tin[l];
}


Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<bridges.size();i++){
      |                 ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Number of queries: 4
2 Correct 0 ms 344 KB Number of queries: 4
3 Correct 1 ms 344 KB Number of queries: 4
4 Correct 1 ms 344 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 728 KB Number of queries: 8
2 Correct 7 ms 1240 KB Number of queries: 9
3 Correct 11 ms 736 KB Number of queries: 9
4 Correct 10 ms 732 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 496 KB Number of queries: 9
2 Correct 11 ms 732 KB Number of queries: 9
3 Correct 11 ms 988 KB Number of queries: 9
4 Correct 10 ms 740 KB Number of queries: 9