# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
428973 | Dremix10 | Simurgh (IOI17_simurgh) | C++17 | 3054 ms | 7360 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;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define endl '\n'
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
const int N = 3e5+1;
const ll INF = 2e18;
const int MOD = 1e9+7;
vector<vector<pi> > a(N);
bool vs[N],idx[N];
int cnt;
void dfs(int s){
cnt++;
vs[s] = true;
for(auto x : a[s])
if(!vs[x.F] && idx[x.S])
dfs(x.F);
}
int mm,nn;
vector<int> ans;
void solve(int curr){
if(curr == nn-1){
cnt = 0;
dfs(0);
for(int i=0;i<nn;i++)
vs[i] = false;
vector<int> arr;
for(int i=0;i<mm;i++)
if(idx[i]){
arr.push_back(i);
//cout<<i<<" ";
}//cout<<endl;
//cout<<cnt<<endl;
if(cnt != nn)return;
if(count_common_roads(arr) == nn-1){
ans = arr;
return;
}
}
for(int i=0;i<mm;i++){
if(idx[i])continue;
idx[i] = true;
solve(curr+1);
idx[i] = false;
}
}
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
int i,j;
mm = u.size();
nn = n;
for(i=0;i<mm;i++){
int x = u[i];
int y = v[i];
a[x].push_back({y,i});
a[y].push_back({x,i});
}
solve(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... |