# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426809 | Hazem | Simurgh (IOI17_simurgh) | C++14 | 2 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
int n,m;
int vis[10];
vector<int>vec,adj[10],ans;
void dfs(int i){
if(vis[i])
return ;
vis[i] = 1;
for(auto x:adj[i])
dfs(x);
}
bool check(){
for(int i=0;i<n;i++)
vis[i] = 0;
dfs(0);
bool ret = 1;
for(int i=0;i<n;i++)
ret &= vis[i];
return ret;
}
void bt(int idx){
if(vec.size()==n-1){
if(!check())
return ;
if(count_common_roads(vec)==n-1)
ans = vec;
return ;
}
if(idx==m)
return;
bt(idx+1);
vec.push_back(idx);
bt(idx+1);
vec.pop_back();
}
std::vector<int> find_roads(int n1, std::vector<int> u, std::vector<int> v) {
n = n1;m = u.size();
bt(0);
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |