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 |
我的为什么死活WA 啊,哪位牛人帮我看下啊#include <iostream> #include <string> using namespace std ; int main(){ string a ; int test = 1 ; while( getline( cin , a) ) { if( a == "#" ) break ; if( a == "" ) { printf( "Tree %d: 0 => 0\n" , test ) ; continue ; } int n = 0 , i = 0 ; int b[10002] , visit[10002]; memset( b , 0 , sizeof(b) ) ; memset( visit , 0 , sizeof( visit ) ) ; int len = a.size () ; int max = 0 ; while ( i < len ) { if( a[i] == 'd' ) { n ++ ; visit[n] ++ ; if( n > max ) max = n ; } if( a[i] == 'u') n -- ; i ++ ; } int maxn = 0 ; i = 0 , n = 0 ; int k = 0 ; while( i < len ) { if( a[i] == 'd' ) { k ++ ; n ++ ; if( k > n ) { n ++ ; k = n ; } b[n] = b[n -1] + 1 ; if( b[n] > maxn ) maxn = b[n] ; } if( a[i] == 'u') n -- ; i ++ ; } printf( "Tree %d: %d => %d\n" , test ++ , max , maxn ) ; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator