# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
757828 | alexander707070 | Simurgh (IOI17_simurgh) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define MAXN 507
#define MAXM 300007
using namespace std;
int n,m,a[MAXM],b[MAXM],res[MAXM];
vector< pair<int,int> > v[MAXN];
bool li[MAXN];
vector<int> tree,ask,g[MAXN],ans;
int curr,where[MAXN],maxres;
bool golden[MAXM],checked[MAXM];
void dfs(int x){
li[x]=true;
for(int i=0;i<v[x].size();i++){
if(li[v[x][i].first])continue;
tree.push_back(v[x][i].second);
dfs(v[x][i].first);
}
}
void comp(int x,int p,int id){
where[x]=id;
for(int i=0;i<g[x].size();i++){
if(g[x][i]==p)continue;
comp(g[x][i],x,id);
}
}
vector<int> find_roads(int N,vector<int> from,vector<int> to){
n=N; m=int(from.size());
for(int i=0;i<m;i++){
a[i]=from[i]; b[i]=to[i];
v[a[i]].push_back({b[i],i});
v[b[i]].push_back({a[i],i});
}
dfs(0);
for(int i=0;i<n-1;i++){
for(int f=0;f<n;f++)g[f].clear();
for(int f=0;f<n-1;f++){
if(i==f)continue;
ask.push_back(tree[f]);
g[a[tree[f]]].push_back(b[tree[f]]);
g[b[tree[f]]].push_back(a[tree[f]]);
}
comp(a[tree[i]],0,1);
comp(b[tree[i]],0,2);
maxres=0;
for(int f=0;f<m;f++){
if(where[a[f]]!=where[b[f]] and !checked[f]){
ask.push_back(f); checked[f]=true;
res[f]=count_common_roads(ask);
maxres=max(maxres,res[f]);
ask.pop_back();
}
}
for(int f=0;f<m;f++){
if(where[a[f]]!=where[b[f]] and !checked[f] and res[f]==maxres){
golden[f]=true;
}
}
}
for(int i=0;i<m;i++){
if(golden[i])ans.push_back(i);
}
return ans;
}