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.h> using namespace std; int i; char str[10010]; int D(int d) { int d1, d2; if(str[i]=='u') return 0; else { i++; d1 = D(d1); i++; d2 = D(d2); return d1>d2?d1+1:d2+1; } } int main() { int j, l ,c, d1, d2,count=1; while(cin>>str) { if(strcmp(str, "#")==0)break; l =strlen(str);c = d1 = 0; for(j=0;j<l;j++) { if(str[j]=='d') c++; else { if(c>d1) d1 = c; c = 0; } } str[j]='u'; i = 0; d2 = D(0); cout << "Tree " << count <<": "<<d1<<" => "<<d2<<endl; count++; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator