| ||||||||||
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 |
aaaaaaaaaaaa,加强版的数据都过了,还是不行啊#include <iostream> #include <stack> #include <cstdio> using namespace std; int main() { int N; stack<int > pp; int i,j,k,flag,top; int a[1005]; while(~scanf("%d",&N)) { if(N==0) break; while(~scanf("%d",&a[1])) { flag=0; if(a[1]==0) break; for(i=2;i<=N;i++) cin>>a[i]; i=1; pp.push (i); while(!pp.empty ()) { for(j=2;j<=N;j++) { top=pp.top (); while(top==a[i]) { pp.pop (); if(!pp.empty ()) top=pp.top(); i++; } pp.push(j); } while(top==a[i]) pp.pop (); while(1) { top=pp.top (); if(a[i]!=top) {flag=1;break;} else { pp.pop(); i++; } if(i==N+1) break; } break; } if(flag==0) printf("Yes\n"); else printf("No\n"); } printf("\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