Блог пользователя ZERO111

Автор ZERO111, история, 7 месяцев назад, По-английски

here is the submission 370310085

here is the tutorial code 370309621

please, help

  • Проголосовать: нравится
  • -5
  • Проголосовать: не нравится

»
7 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I'm not sure if that's the actual issue but I'm pretty sure __gcd isn't O(1) and it's actually logarithmic which means inside of that triple loop you're calling __gcd millions of times.

I'd say you just need to optimize this but I'm not 100% sure.

Also using vector<vector> dp(n, vector(l, -1e18)) inside of while (t--) might be memory risky

»
7 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

the problem is the gcd probably,__gcd and gcd uses different algorithms, I dont know what algortihm __gcd uses but gcd use Euclidean algorithm which is faster