이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
vector<int> p (22);
void initset(int x){
p.assign(22,0);
for(int i=0;i<=x;i++){
p[i]=i;
}
}
int find(int u){
if(u==p[u])
return u;
else
return find(p[u]);
}
/*bool issameset(int u,int v){
return find(u)==find(v);
}*/
void unionset(int u,int v){
u=find(u);
v=find(v);
if(u!=v){
p[v]=u;
}
}
std::vector<int> find_roads(int n, std::vector<int> u, std::vector<int> v){
int tam=v.size();
//initset(tam);
map<int,ii> mp;
set<int> se;
for(int i=0; i<tam; i++){
//unionset(u[i],v[i]);
mp[i]=ii(u[i],v[i]);
//cout<<i<<" = "<<u[i]<<" "<<v[i]<<endl;
}
int c=0;
for(int i=pow(2,n-1)-1;i<(1<<tam);i++){
if(__builtin_popcount(i)==n-1){
c++;
//cout<<i<<" "<<c<<endl;
se.clear();
vector<int> r;
//cout<<i<<" = "<<h<<endl;
initset(n);
for(ll j=0;j<tam;j++){
if(i&(1<<j)){
r.push_back(j);
unionset(u[j],v[j]);
}
}
vector<int> f;
int h=r.size();
for(int j=0;j<h;j++){
f.push_back(p[r[j]]);
}
//int l=r.size();
f.erase(unique(f.begin(),f.end()),f.end());
int sw=f.size();
f.clear();
if(sw==1){
ll common=count_common_roads(r);
if(common==n-1){
return r;
}
}
}
}
//return r;
//int common=count_common_roads(r);
}
컴파일 시 표준 에러 (stderr) 메시지
simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:73:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |