I'd be happy if someone explained the solutions of E and J.
http://acm.math.spbu.ru:17249/~ejudge/files/opencup/oc12/gp6/gpce-e.pdf
# | User | Rating |
---|---|---|
1 | tourist | 3764 |
2 | slime | 3592 |
3 | maroonrk | 3535 |
4 | Benq | 3513 |
5 | jiangly | 3509 |
6 | ecnerwala | 3508 |
7 | MiracleFaFa | 3466 |
8 | ksun48 | 3452 |
9 | Um_nik | 3426 |
10 | greenheadstrange | 3393 |
# | User | Contrib. |
---|---|---|
1 | awoo | 192 |
2 | -is-this-fft- | 191 |
3 | Monogon | 183 |
4 | YouKn0wWho | 182 |
5 | Um_nik | 181 |
6 | antontrygubO_o | 173 |
7 | maroonrk | 168 |
8 | errorgorn | 165 |
8 | SecondThread | 165 |
10 | kostka | 164 |
I'd be happy if someone explained the solutions of E and J.
http://acm.math.spbu.ru:17249/~ejudge/files/opencup/oc12/gp6/gpce-e.pdf
Name |
---|
Problem E.
Let
calc(i, j)
be the maximum coverage length of a special symboli
in the patternP
starting fromP[j]
. Then for each equation of the form A = B + C,calc(A, j) = calc(B, j) + calc(C, j + calc(B, j))
, and for equation A = a word over * {a, ..., z} we count it the simple way.To speed up, use a hash table (unordered_map) to memorize
calc(i, j)
values.The solution is then
calc(S, 0) == strlen(P)
.