| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一星期后回归poj第一题留念~#include "stdio.h" #include "math.h" #include "string.h" #define M 1300 int train[M],visit[M]; int station[M]; int n; int main() { bool flag=true; while(1) { if(flag==true) {scanf("%d",&n);flag=false;} if(!n) break; for(int i=0;i<n;i++) { scanf("%d",&train[i]); if(!train[i]) {flag=true;break;} } if(flag==true) {printf("\n");continue;} else { int top=0,k=0; for(int i=1;i<=n;i++) { while(top && station[top-1]==train[k]) {k++;top--;} station[top++]=i; } if(!top) printf("Yes\n"); else { while(top) { if(station[top-1]==train[k]) k++; top--; } if(k==n) printf("Yes\n"); else printf("No\n"); } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator