Ryan22oct's blog

By Ryan22oct, history, 3 days ago, In English

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

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

»
3 days ago, # |
  Vote: I like it 0 Vote: I do not like it

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

»
2 days ago, # |
  Vote: I like it 0 Vote: I do not like it

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.