# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
6084 | baneling100 | Senior Postmen (BOI14_postmen) | C++98 | 1090 ms | 22112 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 <algorithm>
#include <vector>
using namespace std;
typedef pair <int,int> ppair;
vector <ppair> A[500001];
int N, M, Ban[500001], Ans[500001], Top, S[500001], Len, Check[500001];
void input(void)
{
int i, u, v;
scanf("%d %d",&N,&M);
for(i=1 ; i<=M ; i++)
{
scanf("%d %d",&u,&v);
A[u].push_back(make_pair(v,i));
A[v].push_back(make_pair(u,i));
}
}
void process(int now)
{
int i, j=A[now].size();
for(i=0 ; i<j ; i++)
if(Ban[A[now][i].second]==0)
{
Ban[A[now][i].second]=1;
process(A[now][i].first);
}
Ans[++Top]=now;
}
void output(void)
{
int i;
for(i=1 ; i<=Top ; i++)
{
if(Check[Ans[i]])
{
while(S[Len]!=Ans[i])
{
printf("%d ",S[Len]);
Check[S[Len]]=0;
Len--;
}
printf("%d\n",S[Len]);
}
else
{
Check[Ans[i]]=1;
S[++Len]=Ans[i];
}
}
}
int main(void)
{
input();
process(1);
output();
return 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... |