Submission #115972

#TimeUsernameProblemLanguageResultExecution timeMemory
115972HungAnhGoldIBO2020Easter Eggs (info1cup17_eastereggs)C++14
Compilation error
0 ms0 KiB
#include<iostream> #include<vector> #include<string.h> using namespace std; const int M=515; bool used[M]; vector<int> lis,adj[M],lis1; int now,dem; bool cac; void dfs(int x,int p){ lis.push_back(x); if(!used[x]){ lis1.push_back(x); dem++; if(dem==now/2){ cac=true; return; } } for(int i=0;i<adj[x].size();i++){ if(cac){ return; } if(adj[x][i]!=p){ dfs(adj[x][i],x); } } } int findEgg(int N,vector<pair<int,int> > bridges){ memset(used,false,sizeof(used)); int i,j,k,l; for(i=1;i<M;i++){ adj[i].clear(); } for(i=0;i<bridges.size();i++){ adj[bridges[i].first].push_back(bridges[i].second); adj[bridges[i].second].push_back(bridges[i].first); } now=N; while(now>1){ dem=0; lis.clear(); lis1.clear(); cac=false; dfs(1,1); if(query(lis)){ for(i=1;i<=N;i++){ used[i]=true; } for(i=0;i<lis1.size();i++){ used[lis1[i]]=false; } now=dem; } else{ for(i=0;i<lis1.size();i++){ used[lis1[i]]=true; } now=now-dem; } } for(i=1;i<=N;i++){ if(!used[i]){ return i; } } }

Compilation message (stderr)

eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:20:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<adj[x].size();i++){
              ~^~~~~~~~~~~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:35:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<bridges.size();i++){
          ~^~~~~~~~~~~~~~~
eastereggs.cpp:46:6: error: 'query' was not declared in this scope
   if(query(lis)){
      ^~~~~
eastereggs.cpp:50:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(i=0;i<lis1.size();i++){
            ~^~~~~~~~~~~~
eastereggs.cpp:56:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(i=0;i<lis1.size();i++){
            ~^~~~~~~~~~~~
eastereggs.cpp:31:8: warning: unused variable 'j' [-Wunused-variable]
  int i,j,k,l;
        ^
eastereggs.cpp:31:10: warning: unused variable 'k' [-Wunused-variable]
  int i,j,k,l;
          ^
eastereggs.cpp:31:12: warning: unused variable 'l' [-Wunused-variable]
  int i,j,k,l;
            ^
eastereggs.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^