1 solutions
-
0
C++ :
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int weishenmeCEle[3005]; int main() { //freopen("D input.txt","r",stdin); //freopen("D output.txt","w",stdout); int n; while(scanf("%d",&n)!=EOF) { memset(weishenmeCEle,0,sizeof(weishenmeCEle)); for(int i=1;i<n;i++) weishenmeCEle[i]=i+1; for(int i=n+1;i<=2*n;i++) { int l,r; scanf("%d%d",&l,&r); weishenmeCEle[l]=i; weishenmeCEle[i]=r; } int p=1; while(p) { printf("%d ",p); p=weishenmeCEle[p]; } printf("\n"); } }
- 1
Information
- ID
- 16940
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By