# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
128431 | chubyxdxd | Simurgh (IOI17_simurgh) | C++11 | 28 ms | 396 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<ll,ll> ii;
int p[22];
void initset(int x){
for(int i=0;i<x;i++){
p[i]=i;
}
}
int finds(int u){
if(u==p[u])
return u;
p[u]=finds(p[u]);
return p[u];
}
/*bool issameset(int u,int v){
return find(u)==find(v);
}*/
int unionset(int u,int v){
u=finds(u);
v=finds(v);
if(u!=v){
p[u]=v;
return 1;
}
return 0;
}
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v){
int tam=v.size();
//int c=0;
for(int i=0;i<(1<<tam);i++){
if(__builtin_popcount(i)==n-1){
vector<int> r;
initset(n);
int sw=0;
for(ll j=0;j<tam;j++){
if(i&(1<<j)){
r.push_back(j);
if(unionset(u[j],v[j])==0){
sw=1;
break;
}
}
}
//f.clear();
if(sw==0){
int common=count_common_roads(r);
if(common==n-1){
return r;
}
r.clear();
}
}
}
//return r;
//int common=count_common_roads(r);
}
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... |