pickle_juice2024's blog

By pickle_juice2024, history, 6 months ago, In English

I am getting MLE for this problem and I can't figure it out. Any help would be appreciated: https://codeforces.com/problemset/problem/1775/D

Spoiler
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by pickle_juice2024 (previous revision, new revision, compare).

»
6 months ago, # |
  Vote: I like it +1 Vote: I do not like it

I guess that your code is creating a graph with too many edges. I think in your code, the number of edges from node i is roughly equal to the number of divisors that b[i] has. In worst case scenario, b[i] has around 240 divisors, so we have 240 edges with each of 6*10^5 vertices * 4 bytes per int value = about 576MB, which is twice the memory limit