Hello,
I'm trying to solve 446C - DZY Loves Fibonacci Numbers and i can't debug my code. I'm simply using a segment tree to get the sums.I would really be happy if someone could tell me my mistakes.
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 165 |
2 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
4 | adamant | 160 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
8 | Dominater069 | 154 |
8 | nor | 154 |
Hello,
I'm trying to solve 446C - DZY Loves Fibonacci Numbers and i can't debug my code. I'm simply using a segment tree to get the sums.I would really be happy if someone could tell me my mistakes.
Name |
---|
I guess you misunderstood the problem, for each update you should do following from L to R: a[L] += f[L], a[L + 1] += f[L + 1] ... a[R] += f[R]
nope it says for each l <= i <= r: a[i] += f[i-l+1] thus a[l] += f[1], a[l+1] += f[2], ..., a[r] += f[r-l+1]
Ok, the wrong part is you add pf[q — p — 1] to all a[i] from l to r
i tried pf[q-p] before, still wrong :(
Yes, it must be wrong, you can not do updates correctly with this approach because every element doesn't get constant number and its correct solution isn't as simple as you think, try to look others code or tutorial to get the idea