Submission #945642

#TimeUsernameProblemLanguageResultExecution timeMemory
945642vjudge1Amusement Park (CEOI19_amusementpark)C++17
19 / 100
3034 ms600 KiB
#include <bits/stdc++.h> #define int long long #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back using namespace std; vector <int> g[20]; int cl[20]; bool ok=1; void dfs(int v){ cl[v]=1; for(auto to : g[v]){ if(cl[to]==0)dfs(to); else if(cl[to]==1)ok=0; } cl[v]=2; } signed main(){ int n,m; cin>>n>>m; vector <int> u(m),v(m); for(int i=0;i<m;i++){ cin>>u[i]>>v[i]; } int ans=0; for(int i=0;i<(1<<m);i++){ for(int j=1;j<=n;j++){ cl[j]=0; g[j].clear(); } ok=1; int cnt=0; for(int j=0;j<m;j++){ if((i & (1<<j))){ g[v[j]].pb(u[j]);cnt++; } else g[u[j]].pb(v[j]); } for(int j=1;j<=n;j++){ if(!cl[j])dfs(j); } if(ok)ans+=cnt; } cout<<ans<<"\n"; } /* */
#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...