# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
16848 | kdh9949 | Senior Postmen (BOI14_postmen) | C++98 | 14 ms | 640 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<stdio.h>
#include<stack>
using namespace std;
struct M{int s,e;};
struct E{int dest,next;};
stack<M> st;
E elist[1001010];
int fe[500010],vis[500010],chk[1000010];
int n,m,a,b;
void f(int node){
if(vis[node]){
while(!st.empty() && st.top().s != node){
printf("%d ",st.top().s);
vis[st.top().s]=0;
st.pop();
}
st.pop();
printf("%d\n",node);
}
vis[node]=1;
for(int i=fe[node];i;i=elist[i].next){
if(chk[i])continue;
chk[i]=chk[i+(i%2?-1:1)]=1;
st.push({node,elist[i].dest});
//printf("%d -> %d\n",node,elist[i].dest);
f(elist[i].dest);
}
}
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=m;i++){
scanf("%d%d",&a,&b);
elist[2*i]={b,fe[a]};
elist[2*i+1]={a,fe[b]};
fe[a]=2*i;
fe[b]=2*i+1;
}
f(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... |