Submission #623858

#TimeUsernameProblemLanguageResultExecution timeMemory
623858IwanttobreakfreePipes (CEOI15_pipes)C++17
30 / 100
2391 ms65536 KiB
#include <iostream> #include <vector> using namespace std; #define pii pair<int,int> vector<pii> ans; int timer=0; int dfs(int a,int par,vector<vector<pii>>& g,vector<int>& min_in,vector<int>& t){ t[a]=timer++; min_in[a]=t[a]; for(auto x:g[a]){ if(x.second==par)continue; if(t[x.first]==-1){ int up=dfs(x.first,x.second,g,min_in,t); if(up>t[a])ans.push_back({a+1,x.first+1}); } min_in[a]=min(min_in[a],min_in[x.first]); } //cout<<a<<' '<<min_in[a]<<' '<<t[a]<<'\n'; return min_in[a]; } int main(){ int n,m,x,y; cin>>n>>m; vector<vector<pair<int,int>>> g(n,vector<pair<int,int>>()); vector<int> t(n,-1),min_in(n); for(int i=0;i<m;i++){ cin>>x>>y; x--;y--; g[x].push_back({y,i}); g[y].push_back({x,i}); } for(int i=0;i<n;i++)if(t[i]==-1)dfs(i,-1,g,min_in,t); //cout<<endl; for(auto x:ans)cout<<x.first<<' '<<x.second<<'\n'; }
#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...
#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...