# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
565923 | 2022-05-21T14:31:13 Z | groshi | Easter Eggs (info1cup17_eastereggs) | C++17 | 24 ms | 2148 KB |
#include<iostream> #include<vector> #include<utility> #include "grader.h" using namespace std; struct wi{ vector<int> Q; int odw=0; int dol=0; }*w; vector<int> lista; /*bool query(vector<int> Q) { cout<<"pytam sie\n"; for(int i=0;i<Q.size();i++) cout<<Q[i]<<" "; int k; cin>>k; return k; }*/ void dfs(int x,int ojc) { lista.push_back(x); w[x].odw=1; for(int i=0;i<w[x].Q.size();i++) { int pom=w[x].Q[i]; if(w[pom].odw==1) continue; dfs(pom,x); } } int findEgg(int n,vector<pair<int,int> > bridges) { lista.clear(); w=new wi[n+3]; for(int i=0;i<bridges.size();i++) { int x=bridges[i].first; int y=bridges[i].second; w[x].Q.push_back(y); w[y].Q.push_back(x); } dfs(1,0); int pocz=0,kon=lista.size()-1,sre,ostd=lista.size()-1; while(pocz<kon) { sre=(pocz+kon)/2; vector<int> zapytaj; for(int i=0;i<=sre;i++) zapytaj.push_back(lista[i]); int k=query(zapytaj); if(k==1) { ostd=sre; kon=sre; } else pocz=sre+1; } return lista[ostd]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 312 KB | Number of queries: 4 |
2 | Correct | 1 ms | 208 KB | Number of queries: 4 |
3 | Correct | 1 ms | 208 KB | Number of queries: 4 |
4 | Correct | 1 ms | 208 KB | Number of queries: 4 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 660 KB | Number of queries: 8 |
2 | Correct | 12 ms | 1224 KB | Number of queries: 9 |
3 | Correct | 17 ms | 1772 KB | Number of queries: 9 |
4 | Correct | 16 ms | 1920 KB | Number of queries: 9 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 1864 KB | Number of queries: 9 |
2 | Correct | 15 ms | 1984 KB | Number of queries: 9 |
3 | Correct | 24 ms | 1864 KB | Number of queries: 9 |
4 | Correct | 19 ms | 2148 KB | Number of queries: 9 |