제출 #565922

#제출 시각아이디문제언어결과실행 시간메모리
565922groshiEaster Eggs (info1cup17_eastereggs)C++17
컴파일 에러
0 ms0 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; 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,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]; }

컴파일 시 표준 에러 (stderr) 메시지

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     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:37: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]
   37 |     for(int i=0;i<bridges.size();i++)
      |                 ~^~~~~~~~~~~~~~~
eastereggs.cpp:45:44: error: expected initializer before '.' token
   45 |     int pocz=0,kon=lista.size()-1,sre,lista.size()-1;
      |                                            ^
eastereggs.cpp:55:13: error: 'ostd' was not declared in this scope; did you mean 'std'?
   55 |             ostd=sre;
      |             ^~~~
      |             std
eastereggs.cpp:60:18: error: 'ostd' was not declared in this scope; did you mean 'std'?
   60 |     return lista[ostd];
      |                  ^~~~
      |                  std