#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
vector<int> G[600];
vector<int> nodes;
void linearize(int node,int father){
nodes.push_back(node);
for(auto it:G[node]){
if(it != father){
linearize(it,node);
nodes.push_back(node);
}
}
}
vector<int> que;
bool ok(int le,int ri){
que.clear();
for(int i = le;i <= ri;i++){
que.push_back(nodes[i]);
}
sort(que.begin(),que.end());
que.resize(unique(que.begin(),que.end()) - que.begin());
return query(que);
}
int findEgg (int N, vector < pair < int, int > > bridges){
for(int i = 1;i <= N;i++){
G[i].clear();
}
for(auto it:bridges){
G[it.first].push_back(it.second);
G[it.second].push_back(it.first);
}
linearize(1,0);
int lo = 0,hi = (int)nodes.size() - 1;
while(hi - lo > 0){
int mid = (lo + hi) / 2;
if(ok(lo,mid)){
hi = mid;
}
else{
lo = mid + 1;
}
}
return nodes[lo];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
248 KB |
Number of queries: 9 |
2 |
Incorrect |
3 ms |
312 KB |
Number of queries: 9 |
3 |
Incorrect |
3 ms |
464 KB |
Number of queries: 9 |
4 |
Incorrect |
4 ms |
588 KB |
Number of queries: 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
21 ms |
592 KB |
Number of queries: 14 |
2 |
Incorrect |
55 ms |
820 KB |
Number of queries: 15 |
3 |
Incorrect |
130 ms |
980 KB |
Number of queries: 16 |
4 |
Incorrect |
98 ms |
1084 KB |
Number of queries: 16 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
154 ms |
1148 KB |
Number of queries: 16 |
2 |
Incorrect |
119 ms |
1148 KB |
Number of queries: 16 |
3 |
Incorrect |
107 ms |
1152 KB |
Number of queries: 16 |
4 |
Incorrect |
86 ms |
1152 KB |
Number of queries: 16 |