Submission #1055293

#TimeUsernameProblemLanguageResultExecution timeMemory
1055293andecaandeciSenior Postmen (BOI14_postmen)C++17
0 / 100
2 ms14372 KiB
#include <bits/stdc++.h> #define pb push_back #define int long long #define repp(i,x,n) for(int i=x;i<=n;i++) #define repo(i,x,n) for(int i=x;i>=n;i--) #define cy cout<<"Yes"<<endl #define cn cout<<"No"<<endl #define r0 return 0 #define fi first #define se second #define mp make_pair #define liow ios_base::sync_with_stdio(false);cin.tie(NULL) #define jelek cout<<"jelek"<<endl #define pii pair<int,int> #define all(v) v.begin(),v.end() #define pi pair<pair<int,int>,pair<int,int>> #define p3 pair<int,pair<int,int>> #define p4 pair<pii,pii> #define fl fflush(stdout) #define lb long double using namespace std; const int mod2=1e9+7,mod=998244353,maxn=5e5+5,N=(1<<17),INF=1e18; vector<pii>adj[maxn]; bool visi[maxn]; vector<int>node; int deg[maxn]; void dfs(int x,int p){ // cout<<"x "<<":"<<x<<endl; for(pii i :adj[x]){ if(i.fi==p) continue; if(visi[i.se]) continue; deg[x]--; deg[i.fi]--; if(deg[i.fi]%2==0){ // cout<<"anj "; // for(int i=0;i<node.size();i++){ // cout<<node[i]<<" "; // } // cout<<endl; cout<<x<<" "; while(!node.empty()){ cout<<node.back()<<" "; if(node.back()==i.fi){ break; } node.pop_back(); } cout<<endl; visi[i.se]=1; dfs(i.fi,0); } else { visi[i.se]=1; if(p!=0)node.pb(x); dfs(i.fi,x); } } } void solve(){ int n,m;cin>>n>>m; repp(i,1,m){ int u,v;cin>>u>>v; adj[u].pb({v,i}); adj[v].pb({u,i}); deg[u]++; deg[v]++; } node.pb(1); dfs(1,-1); } signed main(){ liow; int t=1; // cin>>t; while(t--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...