Hi Everyone,

I've tried to solve the CSES — Distinct Values Queries problem based on this StackOverflow answer.

Unfortunately I got TLE for my solution.

Can you guys help me, why I get TLE?

Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official.
×

# | User | Rating |
---|---|---|

1 | tourist | 3880 |

2 | jiangly | 3669 |

3 | ecnerwala | 3654 |

4 | Benq | 3627 |

5 | orzdevinwang | 3612 |

6 | Geothermal | 3569 |

6 | cnnfls_csy | 3569 |

8 | jqdai0815 | 3532 |

9 | Radewoosh | 3522 |

10 | gyh20 | 3447 |

# | User | Contrib. |
---|---|---|

1 | awoo | 161 |

1 | maomao90 | 161 |

3 | adamant | 156 |

4 | maroonrk | 153 |

5 | -is-this-fft- | 148 |

5 | SecondThread | 148 |

5 | atcoder_official | 148 |

8 | Petr | 147 |

9 | nor | 144 |

9 | TheScrasse | 144 |

Hi Everyone,

I've tried to solve the CSES — Distinct Values Queries problem based on this StackOverflow answer.

Unfortunately I got TLE for my solution.

Can you guys help me, why I get TLE?

My solution used "dp on tree" technique. The naive version would have used entire arrays in nodes that represents a discrete functions with its values. Because for every function all the function values are the same except one value, I can represent it with the common value, index of the difference, and the difference itself. Using this simpler representation the calculation of the sum of the functions will have lower complexity.

I wonder if this technique (of representing discrete functions this way) has some other useful applications. Is there any reading about this topic?

Anyway I can search on google, but I'm interested in whether I am the only one who can't use this function of the site, or is it wrong for everybody. In the latter case where should I send feedback to?

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/23/2024 21:55:11 (f1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|