# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
33816 | mohammad_kilani | Simurgh (IOI17_simurgh) | C++14 | 76 ms | 2024 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;
const int N =12;
vector<int> r , ans , u , v;
int n , m;
vector< int > g[N];
int cur = 0 , vis[N] , vi = 0 ;
void DFS(int node){
vis[node] = vi;
cur++;
for(int i=0;i<g[node].size();i++){
if(vis[g[node][i]] != vi) DFS(g[node][i]);
}
}
void calc(int i){
if(r.size() >= n) return;
if(i == m){
if(r.size() < n - 1) return;
for(int i=0;i<n;i++){
g[i].clear();
}
for(int i=0;i<r.size();i++){
g[u[r[i]]].push_back(v[r[i]]);
g[v[r[i]]].push_back(u[r[i]]);
}
cur = 0;
vi++;
DFS(0);
if(cur != n) return;
if(count_common_roads(r) == n-1){
ans = r;
}
return ;
}
r.push_back(i);
calc(i+1);
r.pop_back();
calc(i+1);
}
std::vector<int> find_roads(int N, std::vector<int> U, std::vector<int> V) {
u = U;
v = V;
n = N;
m = u.size();
r.clear();
calc(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... |