# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
16847 | kdh9949 | Senior Postmen (BOI14_postmen) | C++98 | 9 ms | 708 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 E{int dest,next;};
stack<int> 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.top() != node){
printf("%d ",st.top());
vis[st.top()]=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]){
fe[node]=elist[i].next;
continue;
}
chk[i]=chk[i+(i%2?-1:1)]=1;
fe[node]=elist[i].next;
st.push(node);
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... |