이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v){
ll tam=u.size();
//initset(tam);
map<ll,ii> mp;
set<ll> se;
for(ll i=0; i<tam; i++){
//unionset(u[i],v[i]);
mp[i]=ii(v[i],u[i]);
}
vector<int> r;
//int f=0;
//cout<<(1<<tam)<<endl;
for(ll i=pow(2,n-1)-1;i<(1<<tam);i++){
ll h=__builtin_popcount(i);
//cout<<i<<" tiene "<<h<<" bits prendidos "<<endl;
if(h!=n-1){
continue;
}
else{
se.clear();
r.clear();
//cout<<i<<" = "<<h<<endl;
for(ll j=0;j<tam;j++){
if(i&(1<<j)){
r.push_back(j);
}
}
ll l=r.size();
for(ll j=0;j<l;j++){
se.insert(mp[r[j]].first);
se.insert(mp[r[j]].second);
}
ll k=se.size();
if(k==n-1){
//f++;
//cout<<i<<endl;
ll common=count_common_roads(r);
if(common==n-1){
//cout<<f<<endl;
return r;
}
}
}
}
return r;
//int common=count_common_roads(r);
}
# | 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... |