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

Автор __Apocalypse__, история, 4 года назад, По-английски

Hi, I am getting TLE in Problem R — Walk Link to the question. Link to code

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

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

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

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

Did you try to take input by scanf and printf?

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

Try using fast i/o :-

ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

»
4 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

On every solve or pro function call you allocate lots of vectors and than copy them to another function calls, allocating new vectors again and again.

You should probably create vectors once in main function and then pass it into functions by references, like that void solve(vector<vector<int>>& mat, int p, vector<vector<int>>& result). Or even make them global