# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97635 | 2019-02-17T15:02:46 Z | KLPP | Easter Eggs (info1cup17_eastereggs) | C++14 | 4 ms | 560 KB |
#include <bits/stdc++.h> #include "grader.h" using namespace std; typedef pair<int,int> pii; vector<int> nei[512]; pii dist[512]; queue<int> q; int n; int lo,hi,mid; vector<int> v; int check; void build(vector < pair < int, int > > bridges){ check=0; for(int i=0;i<n;i++)check+=nei[i].size(); if(check>0)return; for(int i=0;i<bridges.size();i++){ nei[bridges[i].first-1].push_back(bridges[i].second-1); nei[bridges[i].second-1].push_back(bridges[i].first-1); } } int findEgg (int N, vector < pair < int, int > > bridges) { n=N; build(bridges); //for(int i=0;i<n;i++)free(nei[i]); for(int i=0;i<n;i++)dist[i].first=-1,dist[i].second=i; q.push(0); dist[0].first=0; while(!q.empty()){ int u=q.front();q.pop(); for(int i=0;i<nei[u].size();i++){ int v=nei[u][i]; if(dist[v].first==-1){ dist[v].first=dist[u].first+1; q.push(v); } } } sort(dist,dist+n); //for(int i=0;i<n;i++)cout<<dist[i].second<<endl; lo=-1; hi=n-1; while(hi-lo>1){ mid=(hi+lo)/2; //free(v); v.clear(); for(int i=0;i<=mid;i++)v.push_back(dist[i].second+1); if(query(v)){ hi=mid; }else lo=mid; } return hi+1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 4 ms | 560 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 512 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |