Submission #16848

#TimeUsernameProblemLanguageResultExecution timeMemory
16848kdh9949Senior Postmen (BOI14_postmen)C++98
0 / 100
14 ms640 KiB
#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)

postmen.cpp: In function 'int main()':
postmen.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~
postmen.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a,&b);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...