Submission #302123

#TimeUsernameProblemLanguageResultExecution timeMemory
302123TMJNSimurgh (IOI17_simurgh)C++17
0 / 100
36 ms3320 KiB
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; int N,M,T[500],tmpval[30000]; bool B[30000],checked[30000]; vector<int>res,tree; int par(int x){ if(T[x]==x)return x; return T[x]=par(T[x]); } bool uni(int x,int y){ x=par(x); y=par(y); if(x==y)return false; T[x]=y; return true; } vector<int>find_roads(int n,vector<int>u,vector<int>v){ N=n; M=u.size(); for(int i=0;i<N;i++){ T[i]=i; } for(int i=0;i<M;i++){ if(uni(u[i],v[i])){ tree.push_back(i); } B[i]=checked[i]=false; } int tmp=count_common_roads(tree); for(int i:tree){ tmpval[i]=tmp; } for(int i:tree){ for(int j=0;j<N;j++){ T[j]=j; } vector<int>K; for(int j:tree){ if(i==j)continue; uni(u[j],v[j]); K.push_back(j); } K.push_back(-1); int t=-1; for(int j=0;j<M;j++){ if(i==j)continue; if(par(u[j])!=par(v[j])){ if(checked[j]){ if(B[j]){ t=j; } } else{ K.back()=j; tmpval[j]=count_common_roads(K); } } } if(t==-1){ int mx=0; for(int j=0;j<M;j++){ if(par(u[j]!=par(v[j]))&&!checked[j]){ mx=max(mx,tmpval[j]); } } for(int j=0;j<M;j++){ if(par(u[j])!=par(v[j])&&!checked[j]){ if(tmpval[j]==mx){ B[j]=true; } checked[j]=true; } } } else{ K.back()=t; int hoge=count_common_roads(K); for(int j=0;j<M;j++){ if(par(u[j])!=par(v[j])&&!checked[j]){ if(tmpval[j]==hoge){ B[j]=true; } checked[j]=true; } } } } for(int i=0;i<M;i++){ if(B[i])res.push_back(i); } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...