Submission #62455

#TimeUsernameProblemLanguageResultExecution timeMemory
62455zetapiParachute rings (IOI12_rings)C++14
20 / 100
4026 ms42316 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define itr ::iterator typedef pair<int,int> pii; const int MAX=1e6; vector<int> cur,vec[MAX]; int N,edge,mark[MAX]; void Init(int N_) { N=N_; for(int A=0;A<N;A++) { mark[A]=0; vec[A].clear(); } return ; } void Link(int A,int B) { //A++; //B++; vec[A].pb(B); vec[B].pb(A); return ; } void dfs(int node,int br) { cur.pb(node); mark[node]=1; for(auto A:vec[node]) { if(A==br) continue; //cout<<"edge between "<<node<<" "<<A<<"\n"; edge++; if(mark[A]) continue; dfs(A,br); } return ; } int ok(int X) { for(auto A:cur) { if(vec[A].size()==3) { if(vec[A][0]!=X and vec[A][1]!=X and vec[A][2]!=X) return 0; } else if(vec[A].size()>3) return 0; } return 1; } int CountCritical() { int res=0,l; for(int A=0;A<N;A++) { l=1; for(int B=0;B<N;B++) mark[B]=0; for(int B=0;B<N and l==1;B++) { if(!mark[B] and (A!=B)) { cur.clear(); edge=0; dfs(B,A); if(edge/2>=cur.size()) l=0; else if(!ok(A)) l=0; } } res+=l; } return res; } /*signed main() { ios_base::sync_with_stdio(false); Init(7); cout<<CountCritical()<<"\n"; Link(1,2); cout<<CountCritical()<<"\n"; Link(0,5); cout<<CountCritical()<<"\n"; Link(2,0); cout<<CountCritical()<<"\n"; Link(3,2); cout<<CountCritical()<<"\n"; Link(3,5); cout<<CountCritical()<<"\n"; Link(4,3); cout<<CountCritical()<<"\n"; return 0; }*/

Compilation message (stderr)

rings.cpp: In function 'int CountCritical()':
rings.cpp:84:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(edge/2>=cur.size())
        ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...