답안 #918158

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

using namespace std;

int color[513];
vector<vector<int>> g(513);
vector<int> List;

void DFS(int node){
    color[node] = 1;
    List.push_back(node);
    for(auto to : g[node]){
        if(color[to] == 0){
            DFS(to);
        }
    }
}

int findEgg (int N, vector < pair < int, int > > bridges)
{
    for(int i=0 ; i<bridges.size() ; i++){
        int u = bridges[i].first;
        int v = bridges[i].second;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    DFS(1);

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

Compilation message

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i=0 ; i<bridges.size() ; i++){
      |                   ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 448 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 472 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 508 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -