Submission #46270

#TimeUsernameProblemLanguageResultExecution timeMemory
46270hiddenteslaEaster Eggs (info1cup17_eastereggs)C++14
100 / 100
67 ms936 KiB
#include <bits/stdc++.h> #include "grader.h" using namespace std; vector<vector<int>> adj; int findEgg (int n, vector < pair < int, int > > bridges) { adj.resize(n+1); int temp,temp2; for(temp=0;temp<bridges.size();temp++) { int x=bridges[temp].first,y=bridges[temp].second; adj[x].push_back(y); adj[y].push_back(x); } bool cntbisa[n+1]; int sisacnt=n; memset(cntbisa,true,sizeof(cntbisa)); while(sisacnt>1) { //cout<<sisacnt<<"\n"; queue<int> q; bool visited[n+1]; memset(visited,false,sizeof(visited)); q.push(1); vector<int> stk; int udh=0; while(!q.empty()) { int pos=q.front(); q.pop(); if(visited[pos]) continue; visited[pos]=true; stk.push_back(pos); if(cntbisa[pos]) udh++; if(udh>=(sisacnt+1)/2) { break; } for(temp=0;temp<adj[pos].size();temp++) { int thenode=adj[pos][temp]; q.push(thenode); } } int lol=query(stk); //for(temp=0;temp<stk.size();temp++) cout<<stk[temp]<<" "; cout<<"jawaban "<<lol<<"\n"; //char c; //cin>>c; if(lol==1) { sisacnt=udh; vector<int> yangval; for(temp=0;temp<stk.size();temp++) if(cntbisa[stk[temp]]) yangval.push_back(stk[temp]); stk=yangval; memset(cntbisa,0,sizeof(cntbisa)); for(temp=0;temp<stk.size();temp++) cntbisa[stk[temp]]=true; } else { sisacnt-=udh; for(temp=0;temp<stk.size();temp++) cntbisa[stk[temp]]=false; } //cout<<"sisa mungkin = "; for(temp=1;temp<=n;temp++) } for(temp=1;temp<=n;temp++) if(cntbisa[temp]) return temp; }

Compilation message (stderr)

eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:9:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(temp=0;temp<bridges.size();temp++)
                ~~~~^~~~~~~~~~~~~~~
eastereggs.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(temp=0;temp<adj[pos].size();temp++)
               ~~~~^~~~~~~~~~~~~~~~
eastereggs.cpp:51:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(temp=0;temp<stk.size();temp++) if(cntbisa[stk[temp]]) yangval.push_back(stk[temp]);
               ~~~~^~~~~~~~~~~
eastereggs.cpp:54:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(temp=0;temp<stk.size();temp++) cntbisa[stk[temp]]=true;
               ~~~~^~~~~~~~~~~
eastereggs.cpp:59:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(temp=0;temp<stk.size();temp++) cntbisa[stk[temp]]=false;
               ~~~~^~~~~~~~~~~
eastereggs.cpp:8:14: warning: unused variable 'temp2' [-Wunused-variable]
     int temp,temp2;
              ^~~~~
eastereggs.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...