#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);
}
bool nope[600];
int findEgg (int N, vector < pair < int, int > > bridges){
memset(nope,0,sizeof(nope));
nodes.clear();
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);
while((int)nodes.size() > 1){
int mid = (int)(nodes.size()-1) / 2;
vector<int> tmp;
if(ok(0,mid)){
for(int i = 0;i <= mid;i++){
if(!nope[nodes[i]]){
tmp.push_back(nodes[i]);
}
}
nodes = tmp;
}
else{
for(int i = 0;i <= mid;i++){
nope[nodes[i]] = 1;
}
for(int i = mid + 1;i < (int)nodes.size();i++){
if(!nope[nodes[i]]){
tmp.push_back(nodes[i]);
}
}
nodes = tmp;
}
}
return nodes[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
248 KB |
Number of queries: 5 |
2 |
Runtime error |
3 ms |
692 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
692 KB |
Number of queries: 9 |
2 |
Runtime error |
3 ms |
716 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
716 KB |
Number of queries: 10 |
2 |
Runtime error |
4 ms |
884 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |