답안 #763503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763503 2023-06-22T11:34:52 Z Quan2003 Easter Eggs (info1cup17_eastereggs) C++17
100 / 100
28 ms 23896 KB
#include "bits/stdc++.h"
#include "grader.h"
using namespace std; 
#define MAXN (int) 1e6 + 5 
#define mp make_pair
#define pii pair<int,int>
vector<int> order; 
vector<int>adj[MAXN]; 
void dfs(int u, int p)
{
     order.push_back(u); 
     for(int i = 0; i < (int) adj[u].size(); i++)
     {
         int v = adj[u][i];
         if(v == p) continue; 
         dfs(v,u); 
     }
}
int findEgg(int n, vector<pii> bridges)
{
     for(int i = 1; i <= n; i++) adj[i].clear(); 
     order.clear(); 
     for(int i = 0; i < (int) bridges.size(); i++)
     {
         int u = bridges[i].first; 
         int v = bridges[i].second;
         adj[u].push_back(v);
         adj[v].push_back(u); 
     }
     dfs(1, 0); 
     int l = 0; 
     int r = n - 1; 
     while(l < r)
     {
         int mid = (l + r + 1) / 2;
         if(query(vector<int>(order.begin(), order.begin() + mid))) r = mid - 1; 
         else l = mid; 
     }
     return order[l]; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 23760 KB Number of queries: 4
2 Correct 13 ms 23668 KB Number of queries: 4
3 Correct 12 ms 23724 KB Number of queries: 4
4 Correct 11 ms 23760 KB Number of queries: 4
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 23808 KB Number of queries: 8
2 Correct 18 ms 23760 KB Number of queries: 9
3 Correct 28 ms 23816 KB Number of queries: 9
4 Correct 23 ms 23820 KB Number of queries: 9
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 23832 KB Number of queries: 9
2 Correct 24 ms 23760 KB Number of queries: 9
3 Correct 24 ms 23896 KB Number of queries: 9
4 Correct 28 ms 23760 KB Number of queries: 9