Submission #565918

#TimeUsernameProblemLanguageResultExecution timeMemory
565918groshiEaster Eggs (info1cup17_eastereggs)C++17
0 / 100
2 ms592 KiB
#include<iostream> #include<vector> #include<utility> #include "grader.h" using namespace std; struct wi{ vector<int> Q; int odw=0; int dol=0; }*w; int egg=-1; int ile=0; 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) { w=new wi[n+3]; egg=-1; 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=1,kon=lista.size()+1,sre,ostd=0; 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-1; kon=sre; } else pocz=sre+1; } return lista[ostd]; }

Compilation message (stderr)

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<w[x].Q.size();i++)
      |                 ~^~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for(int i=0;i<bridges.size();i++)
      |                 ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...