답안 #918352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918352 2024-01-29T17:20:55 Z Ferid20072020 Easter Eggs (info1cup17_eastereggs) C++17
0 / 100
12 ms 10052 KB
#include <bits/stdc++.h>
#include "grader.h"

using namespace std;

const int up = 2e5 + 5;

vector<int> g[up];
vector<int> List;

void DFS(int node , int from){
    List.push_back(node);
    for(auto to : g[node]){
        if(to != from){
            DFS(to , node);
        }
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    List.clear();
    int i;
    for(i=0 ; i<up ; i++){
        g[i].clear();
    }

    for(i=0 ; i<bridges.size() ; i++){
        int u = bridges[i].first;
        int v = bridges[i].second;
        g[bridges[i].first].push_back(bridges[i].second);
        g[bridges[i].second].push_back(bridges[i].first);
    }

    DFS(1 , 0);


    int l = 0 , r = N - 1 , mid;
    while(l < r){
        mid = (l + r) / 2;
        vector<int> c;
        for(i=l ; i<=mid ; i++){
            c.push_back(List[i]);
        }
        if(query(c) == 1){
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    return List[l];
}

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(i=0 ; i<bridges.size() ; i++){
      |               ~^~~~~~~~~~~~~~~
eastereggs.cpp:29:13: warning: unused variable 'u' [-Wunused-variable]
   29 |         int u = bridges[i].first;
      |             ^
eastereggs.cpp:30:13: warning: unused variable 'v' [-Wunused-variable]
   30 |         int v = bridges[i].second;
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 4952 KB Number of queries: 4
2 Runtime error 5 ms 10000 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 10024 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 10052 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -