답안 #668638

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668638 2022-12-04T10:16:20 Z Truitadepatates Easter Eggs (info1cup17_eastereggs) C++14
0 / 100
200 ms 131072 KB
#include <bits/stdc++.h>;
#include "grader.h";
using namespace std;

vector<vector<int>> adj;
vector<int> ordre;

void dfs(int actual, int anterior){
  ordre.push_back(actual);
  for (auto v : adj[actual]){
    if (v != anterior){
      dfs(v, actual);
    }
  }
}

int findEgg (int N, vector<pair<int, int>> bridges){
  adj.resize(N+1);
  for(int i = 0; i < N-1; i++){
	adj[bridges[i].first].push_back(bridges[i].second);
    adj[bridges[i].second].push_back(bridges[i].first);
  }
  dfs(1, 0);
  int r = N, l = 1;
  vector<int> islands;
  while (r >= l){
    int m = (r+l)/2;
    islands.resize(m);
    for (int i = 0; i < m; i++){
      islands[i] = ordre[i];
    }
    if (query(islands)){
      r = m-1;
    }
    else{
      l = m+1;
    }
  }
  return ordre[r+1];
}

Compilation message

eastereggs.cpp:1:25: warning: extra tokens at end of #include directive
    1 | #include <bits/stdc++.h>;
      |                         ^
eastereggs.cpp:2:20: warning: extra tokens at end of #include directive
    2 | #include "grader.h";
      |                    ^
# 결과 실행 시간 메모리 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 200 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 194 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -