# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896454 | Servant_of_the_Lord | Senior Postmen (BOI14_postmen) | C++17 | 363 ms | 87480 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
using namespace std;
main()
{
ll x,y,z,a,b,c;
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>x>>y;
vector<vector<pair<ll,ll>>>v(x);
vector<ll>w(y);
vector<ll>u;
vector<bool>t(x);
for(ll i=0;i<y;i++)
{
cin>>a>>b;
a--,b--;
v[a].push_back({b,i});
v[b].push_back({a,i});
}
function<void(ll)>dfs=[&](ll a)
{
if(t[a])
{
while(u.back()!=a)
{
cout<<u.back()+1<<' ';
t[u.back()]=false;
u.pop_back();
}
cout<<a+1<<'\n';
u.pop_back();
}
while(v[a].size())
{
pair<ll,ll>p=v[a].back();
v[a].pop_back();
if(w[p.second])continue;
w[p.second]=true;
u.push_back(a);
t[a]=true;
dfs(p.first);
}
};
dfs(0);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |