제출 #591472

#제출 시각아이디문제언어결과실행 시간메모리
591472andrei_boacaPipes (CEOI15_pipes)C++14
20 / 100
1022 ms65536 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; int n,m; struct date { bitset<2> a; short x; }; vector<vector<date>> muchii; bool use[100005]; int topar[100005],par[100005]; int niv[100005],nivmin[100005]; date getdata(int x) { date rez; rez.x=x%(1<<15); rez.a[0]=((x>>15)&1); rez.a[1]=((x>>16)&1); return rez; } int getnum(date x) { int rez=x.x+x.a[0]*(1<<15)+x.a[1]*(1<<16); return rez; } void dfs(int nod) { use[nod]=1; nivmin[nod]=niv[nod]; for(date i:muchii[nod]) { int node=getnum(i); if(node==par[nod]) continue; if(!use[node]) { par[node]=nod; niv[node]=niv[nod]+1; dfs(node); nivmin[nod]=min(nivmin[nod],nivmin[node]); } else nivmin[nod]=min(nivmin[nod],niv[node]); } int cnt=0; if(nivmin[nod]==niv[nod]&&par[nod]!=0) { for(date i:muchii[nod]) { int x=getnum(i); if(x==par[nod]) cnt++; } if(cnt==1) cout<<par[nod]<<' '<<nod<<'\n'; } } bool comp(date a, date b) { return getnum(a)<getnum(b); } int main() { cin>>n>>m; muchii.resize(n+1); for(int i=1;i<=m;i++) { int a,b; cin>>a>>b; muchii[a].push_back(getdata(b)); muchii[b].push_back(getdata(a)); } for(int i=1;i<=n;i++) sort(muchii[i].begin(),muchii[i].end(),comp); for(int i=1;i<=n;i++) if(!use[i]) { niv[i]=1; dfs(i); } return 0; }
#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...