Submission #428180

#TimeUsernameProblemLanguageResultExecution timeMemory
428180jeqchoSimurgh (IOI17_simurgh)C++17
13 / 100
3071 ms332 KiB
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vpi; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define F0R(i,b) FOR(i,0,b) #define ROF(i,a,b) for(int i=(b)-1;i>=(a);--i) #define R0F(i,b) ROF(i,0,b) #define all(x) begin(x),end(x) #define pb push_back #define trav(a,x) for(auto&a:x) #define sz(x) int(x.size()) vi u; vi v; int n,m; bool done=0; vi ans; int const N=7+3; vi adj[N]; bool vis[N]; void dfs(int now,int par) { if(vis[now])return; vis[now]=1; trav(chi,adj[now]) { if(chi==par)continue; dfs(chi,now); } } vi cur; bool valid() { F0R(i,n)adj[i].clear(); fill(vis,vis+n,0); F0R(i,n-1) { adj[u[cur[i]]].pb(v[cur[i]]); adj[v[cur[i]]].pb(u[cur[i]]); } dfs(0,-1); F0R(i,n) { if(!vis[i])return 0; } return 1; } void recur(int now) { if(sz(cur)>=n)return; if(done)return; if(now==m) { if(sz(cur)!=n-1)return; if(!valid())return; int res = count_common_roads(cur); if(res==n-1) { ans=cur; done=1; } return; } recur(now+1); cur.pb(now); recur(now+1); cur.pop_back(); } vi find_roads(int n1, vi u1, vi v1) { n=n1; m=sz(u1); u=u1; v=v1; recur(0); assert(done); return ans; }
#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...