zen0wu / topcoder-greed

greedy editor for topcoder arena
Apache License 2.0
229 stars 48 forks source link

Always trim first when parsing params. #171

Open ShikChen opened 8 years ago

ShikChen commented 8 years ago

Sometimes even a simple string param may have redundant spaces like sample 2 in BagAndCards (SRM 679). Always trim first when parsing params will fix this.

The incorrect BagAndCards.sample is given below. Note that there is a trailing space in sample 2.

I have debugged my solution for quite a while and found this bug in Greed during the contest...QQ

-- Example 0
2
4
1
1
0
0
NNYYNYN

9
-- Example 1
3
5
1
1
1
2
NNYYNYNYN

1532
-- Example 2
10
20
111
222
333
444
"NNNNNYYYNNNYYYYYYNNYYYYNNNNYNNYYYNNNYYN" 

450750683
-- Example 3
2
2
1
1
0
0
NNY

1