답안 #918123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
918123 2024-01-29T13:12:06 Z fuad27 Easter Eggs (info1cup17_eastereggs) C++17
40 / 100
18 ms 1264 KB
#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int n = 1000;
vector<int> g[n];
vector<int> v;
void dfs(int at, int p) {
  v.push_back(at);
  for(int to:g[at]) {
    if(to==p)continue;
    dfs(to, at);
  }
}
int findEgg (int N, vector < pair < int, int > > bridges)
{
  for(auto i:bridges) {
    g[i.first].push_back(i.second);
    g[i.second].push_back(i.first);
  }
  dfs(1,0);
  int l = 1, r = v.size()-1, res = -1;
  while(l <= r) {
    int mid = (l+r)/2;
    vector<int> q;
    for(int i = 0;i<=mid;i++)q.push_back(v[i]);
    if(query(q)) {
      r=mid-1;
      res=v[mid];
    }
    else {
      l=mid+1;
    }
  }
  if(res == -1)res=v[0];
  v.clear();
  for(int i = 1;i<=N;i++)g[i].clear();
  return res;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 996 KB Number of queries: 8
2 Correct 9 ms 856 KB Number of queries: 9
3 Correct 14 ms 1264 KB Number of queries: 9
4 Correct 12 ms 748 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 776 KB Number of queries: 9
2 Correct 13 ms 744 KB Number of queries: 9
3 Runtime error 5 ms 512 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -