kawatea's solution http://codeforces.me/contest/246/submission/2621642 i think it's brute force because this solution uesd a "for" loop to find distinct names of k sons
kawatea's solution http://codeforces.me/contest/246/submission/2621642 i think it's brute force because this solution uesd a "for" loop to find distinct names of k sons
| # | User | Rating |
|---|---|---|
| 1 | Benq | 3676 |
| 2 | Kevin114514 | 3659 |
| 3 | jiangly | 3640 |
| 4 | turmax | 3450 |
| 5 | tourist | 3382 |
| 6 | strapple | 3360 |
| 7 | Um_nik | 3354 |
| 8 | squareOf105 | 3348 |
| 9 | maroonrk | 3312 |
| 10 | idontwannadothis…e | 3191 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 156 |
| 2 | nik_exists | 151 |
| 3 | maspy | 149 |
| 4 | AmShZ | 145 |
| 5 | Um_nik | 143 |
| 6 | Errichto | 139 |
| 7 | BledDest | 136 |
| 8 | adamant | 135 |
| 9 | maroonrk | 132 |
| 10 | cry | 130 |
| Name |
|---|



It caches every query. It seems that there could not be many distinct large queries.
for (i = p; i < q; i++) { if (f[w[z][i].second] == 0) { sum++; f[w[z][i].second] = 1; } }In the worst case this part works (summary) in
.
Sample:
K+M -> K+M-1 -> K+M-2 -> .... KK -> 1,2,3, ..., K-1K+1 -> some chain of length 1K+2 -> some chain of length 2...K+M -> some chain of length MProve:
Each
times. To view it k times, we should ask about layer
.
w[z][i]will be viewed at mostzfrom k different ancestors ofw[z][i]. How to get k different pairs <p,q>? For each of these k ancestors we have to add a chain from it to layerz. Lengths of these chains will be at least 1,2, ... k. Sum is at most n. So k is at most