Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

Автор 100mil, история, 3 года назад, По-английски

I was solving this problem-https://codeforces.net/problemset/problem/1613/E This is my solution-https://codeforces.net/contest/1613/submission/138713743 Can pls someone tell me what is wrong here.

Теги bfs
  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится

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

The problem is in your check function, you are copying a (vector<char> v )and (vector<vector<int>> vis) every time you call check function. To avoid this make v and vis vector global.

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

The problem in this line:

bool check(int i,int j,vector<vector<char>> v,vector<vector<int>> vis)

Your vector<vector<char>> v and vector<vector<int>> vis are copied every time, when you call this function. Instead you should write somthing like: bool check(int i,int j,vector<vector<char>> &v,vector<vector<int>> &vis)

there is your AC solution with this fix 138716320

And write "\n" instead endl, because endl flushing output, what takes time (sorry for my bad english)