|
|
Becuase of edge cases,this problem take me many hours. So I put one correct sorting function here. struct ND{// Single bracket sequence int len,mn=0; int cnt=0; int id; // len is the length of the bracket sequence // if we define '(' as +1,and ')' as -1,the minimum prefix sum of the bracket sequence is mn. // and the total sum of the sequence is cnt // id is the index of the bracket sequence in the given input. }nd[maxn]; bool swap(ND& a,ND& b){ if(a.cnt>=0&&b.cnt<0)return 1;// a first if(a.cnt<0&&b.cnt>=0)return 0;// b first if(a.cnt>=0)return -a.mn<-b.mn; return -b.mn+b.cnt<-a.mn+a.cnt; } Edited by author 09.05.2025 09:16 Try this: Test 1 input 1 ()) output 0 0 Test 2 input 1 () output 2 1 1 Test 3 input 2 () )( output 2 1 1 Test 4 input 2 () () output 4 2 1 2 Test 5 input 2 ((( ))))( output 0 0 I had WA 9 too, but now I have WA 11... I know, maybe you can try this. input (( )( )) output 6 3 1 2 3 I've WA #11 and my solution passes your tests. Maybe you know another interesting one? 6 )))((()(())(()()()())() )) (()(( (())( ()))(())( )))) Helped me to pass 9 Try following tests: 4 (( )( ) ))( 8 4 1 2 4 3 6 ((( ( )(( ))( )))(( ()) 14 4 1 5 4 6 I had some huge problems getting from WA9 to AC. Here is a test that might help you out: Input: 3 )))(( )))) ((((( Output: 14 3 3 1 2 Tell me how you solved this problem(E-mail: scarlet.flower [at] list.ru). same thing. give some tests, please I don't have tests, but my bug was the following: when I sorted sequences, ones with negative balance should be sorted in the symmetrical way with the sequences with positive balance, and I've compared them wrongly. Edited by author 04.11.2012 17:36 Edited by author 23.06.2012 12:37 4 )(( ( )) ))((( 20 )(( ( )) ))((( )(( ( )) ))((( )(( ( )) ))((( )(( ( )) ))((( )(( ( )) ))((( 200 ())()))))((((((()()())())())(()()()((()(() ()((()())(((((())()))))))))()()))(()(())))))())()(()))((((()))()()(()))(((()))()((()()))()))((((((((((()()))))())()()()()((())())))()( )()(())))(()()((()(()()(()(())()))(()(((((()()))))))(()(()))))()()(() ()))())))((()))())(((())(()))((()(((()()())(())()(()())(()(()())(((()(((()(((())())())()()((((()))(()()))()))((()())()(()))(()())))(()()(())))))(()(()(()())( )(()(((()()((()(((())))))()()))((())(()))()(())))())(()))())()))()()(())())((()((()()))()(((())))))(((( ))))()()()())((())(()()()((()))()()()()))(()))()((((())()()((((((())(()))))(()(((((()()())(((((()))(())((()())()())()(((())(()))()()(()))())((())()(()(()( ))(()()(((())(()((((()()((((())()())()()))(()((()()(()))((())))(((())())()((()))()((()()()))(()))()((((()((()(()(((((())))()))))(()))()(()()( ))((())())((((())())(())))))(( ())(( ))()))))))((()(((()))))(())))()()()))((())))))(()()(()(())()))((()()((((())(()())()())((((((())()(((()())))())))((((())()())(()()(())))(()((((()()())(()))(()()(())))) ()))()()(()()(()(())))((())))()))()))())()()()))()(()())())))())))((())()))))())))(()()( ()())(()()))()(()() ))))()(((((()))()()()(()()(()()()()))((((()(())))(()())))))())((((((((())(())()()(((()))()))))()))(())))()))()((((())()())()))()()(()))()()))()()))((()()()())))()))())((()())()()()(()(()()()(((())()( )(((((())))()(()))()((((((()))))())()()())))))()((()(())))(()()(((())()))))())()(())))())))()())(((((()))(()(()))(())())(((())()()))((()(())()((((()()))))()((())))()(()()))((())(()))()()))()()) )())())()(()((())))()()(((())(()(())(())((())()))((())(())((((()))(())(())((((())))((()(()((())())()))(((((()(()))(()))()))(()((()(())()(((())())())()(()()())))((((()(((())(((()(()(())(()(())()(()()) )())())()()()(()))))())(()())(((())((())()()()()(((()()))())())((((()((((()((())((()()))(()))(()()())(((((()(())())((()()))()()()))())))))()))(()())( )()()()(())()()()))))()))((((()(((((()(((()(())))(())()(()())()()))((()((()())(()()((())(((((()(()(())))())(())((()(((((((()(())(((()())))(()))())(())()(()) ((())()(((()))()))(()()))()(())(((()()()(((()() ()))(())())((()))((()((((((()((())((((())))(()((()(()()(()((())))())())(()()())))(((((()(()((()()()))( (()(()(()(()()()(((()()))(((()()()(())()())()())))(()())( ))((((()())((())()()())()))()(()()(((())()((())())))()()())))())(((())))))(())(())(((()((())(())))(()())(()(()((())()(())(((()()()(((()((()((())((((((()()))()())())))(()(()()))))((()))((()( (()()(((()())()()(((((()()(((()()(( ())()())()()())(( ()()) )((()))()(()))))(()((((()))(())())())())()((()()(()(()(())(())))()(()()()()()()(()(((()(()(()())())())((()())())()()((()()()))())((())(()()((((()(()(((()(())((()())))(()))()()(())(()(((()))) (())))))()())()(()))))()))()))))(())())()))()))(()(())()))()()(((()()()((()))(()((()()()()() )(( (())((((()(())()()()()(())(()()((()()))())()(((()(()(()))))()(()()) )((()))(()(()(()))())())))()()))()(((((()))(())))()()))(()()()(((())(()((()(()()(((((()((())((())(((())((()((((())) ))()))(())))(((((()))())()()))))()(()((())(()(())))))((()(()()(((()(()((()() ())(((())()())()())))()()))(()((((()(()()()))()((())((()))))))()(((()(((())(((()()(())(())))))( ))))(()()))))((())(()))))(((()()(()())((()((()()())(()(())(((())))((((((())()(()))(()()))))()()(((()(((()(())()())))(()(())(()))((())()()())(())(((()()))(()((())()()) ()()()())((())))(()(()((()((()((()))(()(((((((( )))))))(()())())()(())(((()()((()(()(()))))()))))(()))(()(()(()((()(())))()(())()()(((()))(((()))()()())(()(()()()()(())()()(( ))())()((())()())(())((()(()(()))((())))((())())())))())(())()(((((())))(())())))))())()((()()))(((((()))(()((())(()((())((()(()())()()))((())((()())((((())(())))()()(((()))()))((((() (())))(())))))(()()))(())(()((()(())(())()())))()()(((()())(()()(()(()(())(()))()()))()((()(())(()))()(()))))())))()()))()()()))()()()( ))))()(())))()())))())(()))())))())()((()))()(()(((((()()(()())(()))())()(((((())))((((((())))(()(()(()()()(())((())(())))())))(((()())))))()))))(()(((((()()())(())())()(()()()()()())((()))))) )())()())()))))))())))(()))(())(())()((()())(((((((())((()((())((())()))((()))))()())()))))()))))(((((())(()()((()())(((()))))(((((())((()(()(())())))( )())(()((((((((()(())))()))))(()()()))())(()))(((()()()))()(())))()(()()((())()))) ()))))()))(()())(())))(()()(()))(()()))(((()(((()))((()(()(()((((((()))()())))())())))()(()())()()))())())(((()(())))() ()()))()))(()))))))))()(((()(((((()()(()(())(()(((((())))))(()))))(((((((())(((()((())(()(()(()(((()((((()())(()(()(()(((()()()())(()))(()((())()()((()))))()))(()))())) )))()()))))(((()(()))))(()())(())())()))()))())))()(())((((())(((()( )()))))(()))))(()))))()))())))()()((())()()(( ((()()(())())( ()(())))()())(((()))()())))()))((()((((()((())())))(((())))())))))(()())))(())()(())(()))()(((()()))(((()(()())()))))(())))()))(()()((())())())))))((())(()()((()))()))(()))())(())(())))(()) ())(()()))(()((())(((()())()((())()()(()()((()()))((( (()((()))))))(()((()()(()())))()())))()()(((()())()()( )(()))(()()((()()(()((()((()(((()))()(()(())))()))((( ))()()())(((((())))((())())))(()((()))()()(((((((((()(())())))(()((((((((((()()((()(()(()))()())()) ))))))((())())))))())()))))))))()()()())()))(()))(()()))(((())()))(())))((((())))(())((()(()))))))((((((()(())))()))))))((((((((()())))((()()()))()((((()(()((())))()( ()()()))(()))(()())(((()((())()((()))((()))))()))()()(()(((()())))((()()()))))(()((()())())(((()))))())()))(()((()()(()))()(()()))()((())))()))()()(()))(( )()))())))()((()((()((()()))(()(()))))((((()()))(((()))()(((((()((((())()))(()((()(()()()()())))((((()()))))())))))((((()())())))))()((((())(()()))()((( )()))))()(((())()()((((((()()())))()())())()(())(((((())()))()((())()()))(()((((((()())()()))((()()())))()((()((()(()(()())((((((((() ))))(()(()()())))))(((()(((()((()))(((()())((())(()((( ))(((()((()))(()))())((()()()((((())())(((())((()))))())()(((()()))(((()))( )))(())))())(()(())())())))(()(())()()(()()())))))())()))((()( ))((())()(()))(()(()))()()()((((()((()))))((((()(((()))()()))())()))(()))()()((()))()(((()(((())())()(())()))(()(())()))(((((((())((((((()(())))(( )()))())() )))))(())()(())()(()))(())(()(((((()(()(()) )( )(()(())()())))((())()(())(())(()()(()))))()(()()()()(((())(((((()())((())))((())))()))(()())))())()))))()))(()()()(((( ()())((()()()()(())()(((())(( )()())))(((())()(())())()))))((((((()))(())))()((()(()(()(())))))()()(())((()((()))()))()(())))))((((()(()())()))(())))()((()))(()()()())(((()(()()))()())(()(()()(()(((((()(()()((()(( )(())(() ((()((()))())(()))()(())()())())))())())(((()))))))(())((()())()))()))()()(()()()))()(())())()((()))))((()()())(())((((())(())())()()))))())))())()))))))))))((((()((())())())(()))((())((()(())(()()()) )(()((()())(((()()()))())(())(()(((((()(()()))())(((()((() )(()()))))()(())()(()))))(()()()()((()))((()(()(()(((()(((()((())(()(((((())()()(()((()(()(()())()())()((())(((())()(())))(()(()()((()(()())))((())())()(()()())()((()()(()(()(((())(((()))))))())(( (()((())()(((((())))))()()(()(((()(()((())((())(()))(()()()()))))(()())()))))(()(((())()))((())())()((()())()(((()()))())()(()((()()(((()((())(()())(()))(())()(()()()( (()(()())(()))))()()(((())))(()(((()(((((())()))(())())(((((()()(()((()((((((()(()())( )(())(((((()))()()(((()(()))()())()(())(()(()))())())(((())()))()()(((()((()))))((((()))) )(()())(())))(()(((()(((()(()())()()))))))((()))())())))(())()(((())()(((()))())))))))(()()())))()(()())())))(())()())(())))((()(())()()())(()))(((())(((()((((()()()())(()()))((()()))(()())(( ()))))))(((())())(((()(()()()(()())(((((()()())))(()()())())((()() ()())((()((()()((((((())(()((()())()())()(())(()))))())()()()))()())()()())))()())())())((()))(()(((()((()(((((((()))((()))))())()()()(()))()(((())((()())()))((()()((((()()(()(()()((()))())))() )()(()()(((())((())())()))()((((()(()(()))((()()()))()())()()))())(())))))(()((((((()()()))()(((()))())))())))))((())((()(())))(((()()(())))))(()(()()(())) )))())()(()(()))((()())((( (())))((()))))))(()())()()((())())((((()))(()()())((()())(())()()))))(())))))()))(((()()()(())))())(())))(())())()()(()((()((((((()))()))()())((()()(((() (((()())()((((())))(())()())(( (())())())((())(())(())(()()(()(())(()(())()(()))((()(()()())))((())()())())(())())))(((((()(()))((()()())(((()((())))((()()()())(()))))))((( ))())(()))))))))()())(())(()()(()()()())()((()((())(()))())(()(((((())()((())()()(((((( )(()(((())((())())))()(()()))()))()))((()(()))(()())((()(()())))()()(())())(()))))(((()))()(()()(((()((( )()((((()()))(()))(()()(()()((((()(())((())()))))))()(()))()()())((((()(()))((()))()))))))))(()(())))))))(((((()))()))))((((()() )(()))))((())))(((((()(((()(()())()))))))((()))())(((((())()())((())(((())))(())()((()()))())((()))(()(((()))())))((((()())()))()()())(()(())()()(()(())()((((())( )())()(()()))())()(())(()))))()())))(()))()))()())))))))))(())()(((((())))))(())()())()((((()(()((()(()()()))(((((())())(()())()((()(()((() (((())()()()))))))))(((((())()()))()(())()()(()))(())))))((()))( ()))(()()(()))() ((((())))((((())(()()()(((((())()) (()(((())((((()(()()))))()))(((()()())((( (()()(())(())((())))()(())()()))))()())((())()())()((()))))()))))((((()))))(((())((((((() ))(()()((())())((((()()))(()(()))((( )()()())))((())))))())()(()())())()(())))))((()())()()))))()()()(())(()(( (())(())())())())))(()()()(()()))))(((()))((()((())(()()(()())))())())))(()(()(()())()()()(()))()( ()))()))(((((()(())))((()()((()))(())()()(())((((()((())))()()())(())))(()((())(())()()()((())((((((((()(((()())()(((()((()( ())((((())())(((((() )((()(())))()(((()((()))))))(()(())())())(()))(())))))())(((()))))(()()(())()) (((()(((()()(((()))())()())(())(()))(()))))((()((()()(()))))()))(()()()(()())))()(((())(())))()))()))))((()()((((()((()()(()))(()))((((()(())) )(((()))())(()()(()()(()())(()()((((())(())(())(((()((())((()))()())((( ))((())()))))))()()()))))()())()()()()(())))()()))()))(()())((())((())())(()()))()()))(()())(((())((()((((((()()(())))()()))))(((((())()())())((((( ))(())(((()()()()((((((())))(()((()(((()))()))))(()(()((())))(()(()()()(())(())))(())(())))((((()(()))(()((()())))((())()))))() ())()) ))))()())()(()((()((()())()((((((((()))(()()())(()((()))()(())())(((())()))())((()()))(()())(()()()(()))(()(()())))()()())))()(()) ()()(()((()))))))(())))()())(()((()())))()()(()(()(()()))))))))()(()(((((((())))(()(())()()))((()(((()()(()(()))()))))()((()((( ()()()(()()))))()()))))(()))(()))(((()))())))(())(((())))(((()()(())(((()()((()(()((((((((())())))()()))((((()))())(()(((((()(())()((()))()(()(()()(()())((((()))((((()()))())()()((( )()(()())))(()()))()(())( )((()()((()))(()))()))()()((())((()())))((((())()()(()((((((() ))) (((()))((())()((((((()))))()()((()((())())))((()))))( )((((((((()))((()(()())))()()))()))(())(()()))(((()))))()())(()(()))(()))))())()))))))())()(()))()()))()()))(((()())))))(()(()))()()()()((( ()(()))()))())))())())))()( ))()))()()))(((()()))()((())(())(()(()()()(()))()))((())()(()()(())()(()())())((()))()))()(((())())))(()()(()()(()()(()))((( )))))))()())(()((()()(((((()((()))(()()((())()))()(()(()((()))()()((()((()(()))))()((())(()))()())())(())))()())()()))((()((())))(((()))(((()())(()()(()()) ((()(())(()((()(()(()(()))))(((()()))())()))))((()()))(())))((())((())((())((((()())))(()((())))(( ))))))()((())))))((()(((((())())()(()(((()))()()((((()(()()))))(()()()())(((()(()())((()))()((()(()))(((())(()((()))((())()((((())()( ))))((((()())()((())((()))())(((()))))(((()())((())))))()))()()))(()(()())))((())())(((((())()())()()))))())())())))))()))(())()()(()()))(()()()))((())((()((()()(((((()))((())()(((((()()(())(((( ))))(())())((()(()())()(()()()))())))()()))(((()))(( ((()())(()()()(()))())()))))((()(()))(())()(())))))())(())()(((()(())())()))))())())((())((()())(()(())))()()(()))((())()()())(()()()))())()) )((()()()((((()())))(()(((())))((() )))))()())))()()())()(()))()()())(()(((()))())()()(()))))((())(()()())))(()()())))()(())(((()(((())()(((()))()))(((())()))())())(((())))()))((((((())(()(())))(((()(())())))))(()((()())( ))()))()((())()())))(()(((((()(()))()(()))()))(())))((()())()))()( )()()((((()))(()))()(()))))(((())(()())((((((()((()()())())((()())())(()())(())))))))()))))(()()))()(()())(())()(((((((()))(())))()(()())())((()(()())(() ()(()((()((((()()((()(((()))))))))((()))()(((()()())))(()((((((())()()(())))()(()()( ))))))()()(())(()()(())(()))()))(()))))()()((()((())))))(((())()))())()(())()(( ))))))()(()())))((() )(())()()))))(()((()(()()(()())))))))((((()(())))()((())() )()))(()(()))))())((((((()())((())())))())(()(()()())(())((((()))))))((()())))))))())(()())(()(()(((( ))())()))())(())()))))((((((())(((())))((()()())()((()()))()() ())())()()))()(((()()())(()()(())((())((()))(()()()())(()())(((())))()(())(()()))))(()(((()(()())))())(()((()(((()(()()())(()())(((((((()((()((()())(() ())())()(((()())) )()))()(()(()())))()))())))()(()((((()()))(())()()(((()))((((()))()) ))))((())((()(()))))(())(())((()()(())((((()())())(()))()()()()))()()(((()())))()(()((()(()(((((()(())((())())(()( (())))))()())()((()(()()()(()()()()(())(())()(()(())()))(((((((()))())((((((()(()()))())))(()((((((((()((())((()(((())(())()(((((((()))()(())))))()()()((()()))((())))()()((()((()())()())())()((()(())) )(()()))()))(()())()(()))(()))(()))()((())(())))))()())))((((()))()(()((()((()()()()())(((()()))))()(()(()))(()(()(()(()))))))(((()(())()(((( ((())())(()()((()(((((((((())(()(((())()))()(((((()()())()())()()())())(()))(()()))((()(()(())((()))()))( (()())())))()))()((((()))))(())(())()()()((()())(()(()((())((((())())(()())(())(()(()(()))()(())((()())(())()))))(()(()()())((()()))()()(((())))()))()((()())))(((()))))))))))))))((())))(()) ())())(()(() ((())())(()))((()(()()(((((((((()()))())()(()(((()))))()()((()))(((()()((((())(()))((()(()))(()((((()(()((()))))(())()((()))()())()((()()( ))((()(())))(()))))))))())))(()))())))((()))()((((()()(()()())()))())((((((()))(())())()())((())(())(()))()))()((())()(())())()(()))()())())(()(())()((() ))()))((())( )))((( ))()(((())(()())(((()()((((())))(((((()((()()(())((())())(()))))()((((((()((()())()())()()(()(((()(()()(())(()())()((((()((((())(()(()))))()()(((()(((())(()))(())))()()())((()()())()())(()))))())) (((((()())(((()))()()())(()()(()())(()()((((((((((())))(()(()()(())((()()(((()))(())()(()((())(((()))(()))))())()())))(())()))())()(()(()()((( ))()()())())()()((()()(((()()()(()(((((((())()))((()(( ()())(()((()(()))())(((()()))))((()) (((())))())()((())()))(((())())))))(((()((((((()()))(()())))(())(((()(())))))()(((((((())))()()((())())(()())( ((()())))))()()))()((())()(() ())(())()()((((()))))))(()))()())))))(()(((((())())())(()))(((()((((()((()))(()()())(()((()))))))()()()((())(()))())()))))(((((()()((()()))()))()))(()())((((()()(()))((()()())())())( ))))())(()(((()(()()()))()()((((()()))())(()))())())()))((()())()()( )()()(()(())(((((((())((()))))))()()())())))((())()))()(()()())) (((()( ()()))(())()()()(((())()((()((((())))(((()))())))()()((()()(()((()((()(()()())))) )()((()))((((())()(( ())()))())(()()()))()))(()))())))()()() () (())()())((()))))))())((()(()))()((()(()()(()))))))()(()(())())()()))))))())(()))((())(((()(()())))((((())()())))))(()())()())()(()()(()((()(((())()((((((())())(()()) )(())))((()()(()))())(((())((()))((())()))((((()(()(()(((( )(()))()))((()(((((()()()()()))((()(()))))()(()(()))()()))))()(((((()())()(()((()))()((())((((()())))((())()()()()(((((((()))))(((((())))(())())))(())()()))())())()))()(()))()))(()()(()()((())() ))()())(()))()))()))())())))()(()(()))))))((()()((()((((()((((()())(()(()()((()()((()())())((()()(((()(())()()((((()()((((())()()()())))))) )()())((())))))(())))(()(())(( ))())()())()(((()())()())())( ((()(())(()()(())(()(()()(((()))())((((()()))())()((()()()))(()))))))((()()())((((( )(())(()())()()))(())()()))()(()))))) ) ((()))))((()(()((((())(((()()((()))(())(((((())(( ()))()())))(()()((())(()))))(()))())())))(())())))((((()()())))))((()(())(()))))())())(())((())))))(()()()(()()(())((())(())))))))(()((((( (())()((()((()(())))())((((((() (()))(()((())()((()()()(())))())))(()())()))()())())))( ()())()))())((()())))()))()()())()((())())()(()(()))))))((())))(()(())())())(()(()(()()()(()(())())(()(()())((()()))))()()(())))))) ()(()))))((()(((())))(((((())()(()(()))((( ()())()(())))()())())(()()))))())))()))(((()()())())((((())(((()((()))))())(())()((()()(((((()(((())(((()(()))(())())((()( ((()))))()(())((())())()))))()())((((( ()(())))((((()(()))(()()((()((((())(()()())(()))))))(()))()()())()))))(((((((()())()(()(()))))(((()((((()))()(())))(()()((())())()))(()()()()()()()(()()))(()))())(()())())(((()(())(((())(( ))))())(()))()((((())))((())((((()(()(())()(())((()())))( (())())())(((((())((()((())()((()()()((())())(()))(())))(())()))())((((((()())(()))))())))(()()()(())(())()(()(()())(())()((((()()())))())()())())()((((()(()))( ((())()())()()(()(())(()))(()))))((())((((())))())()))())()))()()())))()())())((((()()))((()((((()(())()(()()())))))(()()()))(()(( ((()))(((()))())()))())))((()()()()))(()()((())))((((())()))()(()))))))())())()) ((((())((()()()(()(((()(()()()())))()))))(((())()(((())) (((())())(())()(()))())()))(((())()()()))(((()())()()()((())()(()(((((()(((()))(()))((()(()())(()))())))((((((())())(((((()(((()((()(()())())(())()((( ))()(())))()((((((())))())()(()((((()())())(())(()))(()(((()((((((((())())))()()())())((()((())()(())))( ))()(()()((()((()( )))(((()())) ((((((()()))))(()(())))))(())()))()(((()))))())()))(()(()())())()((((((()((())))(()))()()()(()))))(())())()()())()(()())) ((((()()(((()))(((())(((())(()(()()()))))())()(()() (((())()())(()))()(()) )))((()))(()(((()))()))()))(()())())())))))(()(()))()(()())((()()()()((()())))()((())))(()())((((()())))()()(()(((()(((()))()()()(())(())) (())()(())()() )((()(()()()))((())((()(()))())((()())))))))))))(()) )((()((((()))))())())(()()((())()(())(((())(()))()()()()()))((()))()(()(((()))))(()))())))((())())((())())()))))))))))))(())(((()(()()(()))())(((((()(()(()())()(())((())))(()()))()()(()(( )())))(())((())))))())(()(()()))))))())(((())()())))))() )(())()(()())))())())(())(())()()()))(())(()(()(()))))))))() (())(((()))(()()())()(((()())())(()((())))))(()()((()((())()(()(()(((()()(()()()(()()((()))) (((((()(()))()))())))))((()()(((()()(((((()()(()()))()((((()(()))(()))(((()((((()))()()()))(()(((((()()))()()))())()())))()() ()()))()())(((()(()))(()()()()()((()(())(((()((((()(())))()())))(()(())))())(((((((((()))((()((())((((((())(((((()((())(()()()())(((((()()((()()()))()(()))()(())(((())))(((())((((()()))())((( ()())(()()(())))(()((()(())(( ((()((()))(((())()()(()()((())(())()()))(())())(()()()((()())(())()()())()))() ((((())(()))((()((()((()))))())()))()))(())()((((())()())()(((((()))()())()(()()(())((((()())((()()()()))(())())(()(()()(())(()))()((())()()(()))(()())((()())((((())))()())()())(((()))())()( ())))()(((((())))(()((()))()((())(()))((())(((( (()((()())) )) )))()(((((())(((())()(())((()))()(((()))())()))()))()())))(()))()()))())()()))))()()(()(((())(())))(()(()))())))))()(( )))()((())((((((((())(()())())(((())))((((()))))(((())(()((())())))((((()((())())((())(((())))()()))(()))((()))))())))(())((((((()(()(()((())(((((())))()((((())(()))))))())) )()()((((())((((()()( Edited by author 04.02.2010 11:20 6 3 2 1 3 48 15 18 5 9 13 17 4 8 12 16 20 3 7 11 15 19 18272 184 120 152 106 196 193 184 175 28 182 181 159 189 132 68 140 20 77 9 96 194 60 18 116 135 70 64 142 62 172 57 55 46 139 48 134 104 98 7 192 111 149 89 176 78 19 49 154 138 15 167 190 191 195 199 75 126 92 170 155 25 177 129 73 82 1 100 130 143 31 53 21 72 6 171 4 59 52 54 17 67 95 29 80 110 32 63 30 112 35 102 41 79 168 156 113 83 97 38 50 101 131 153 71 76 186 10 88 34 42 16 173 124 125 163 13 26 109 117 145 169 128 119 65 61 183 5 2 81 123 157 56 43 47 37 90 107 136 114 121 122 3 40 8 11 51 91 146 137 144 198 23 36 108 12 165 118 74 84 179 127 103 158 161 14 166 151 39 147 185 160 187 188 45 58 133 85 174 99 115 24 197 94 105 180 I tried to use dynamic programming but failed.Who can tell me how to do it? Thank you very much! |
|
|