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

Автор Ryan22oct, история, 5 дней назад, По-английски

submission link, problem link, Could someone please help me understand the cause of the error? Additionally, i would appreciate general insights into which operations in C++ are typically slow and tips on how to optimize them. Thank You

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

»
5 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
5 дней назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In C++ generally loops run upto O(10^7) in 1 second ,that's why inputs are given such that there complexity is given upto atmost (1~5)*10^7.

Your solution runs O(n*1023), i.e max can reach > 10^8. Which may require like 10 seconds.

Also you are initializing your arrays a and p which is not required.

Also yor inv is input independant so you can precompute it before the loop of testcases.