# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115984 | ckodser | Senior Postmen (BOI14_postmen) | C++14 | 592 ms | 71436 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 int
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define pii pair<ll,ll>
using namespace :: std;
const ll mod=1e9+7;
const ll maxn=5e5+500;
const ll inf=1e9+900;
vector<ll> ger[maxn];
ll s[maxn];
ll t[maxn];
bool vis[maxn];
ll l[maxn];
vector<ll> ans;
bool inAns[maxn];
void dfs(ll a){
while(l[a]<ger[a].size()){
if(vis[ger[a][l[a]]]){
l[a]++;
}else{
ll e=ger[a][l[a]];
vis[e]=1;
dfs(s[e]^t[e]^a);
}
}
if(inAns[a]){
while(ans.back()!=a){
cout<<ans.back()<<' ';
inAns[ans.back()]=0;
ans.pop_back();
}
cout<<a<<endl;
}else{
ans.pb(a);
inAns[a]=1;
}
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n,m;
cin>>n>>m;
for(ll i=0;i<m;i++){
cin>>s[i]>>t[i];
ger[s[i]].pb(i);
ger[t[i]].pb(i);
}
dfs(1);
}
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... |