Submission #1137539

#TimeUsernameProblemLanguageResultExecution timeMemory
1137539footbelikeTracks in the Snow (BOI13_tracks)C++20
100 / 100
748 ms98348 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int ans = 0, amount = 0; int n, m, score, x, y; char a; cin >> n >> m; char board[n][m]; bool board2[n][m]; for (int i = 0; i < n; i++){ for (int j = 0; j < m; j++){ cin >> board[i][j]; board2[i][j] = 0; } } char moves = board[0][0]; if (moves == 'F') a = 'R'; if (moves == 'R') a = 'F'; if (moves == '.'){ cout << ans; return 0; } ans = 1; board2[0][0] = 1; deque <pair<int, pair <int, int>>> q; q.push_front ({-1,{0, 0}}); while (!q.empty()){ score = q.front().first; x = q.front().second.first; y = q.front().second.second; q.pop_front(); if (x != 0 && !board2[x-1][y]){ board2[x-1][y] = 1; if (board[x-1][y] == board[x][y]){ q.push_front({score, {x-1, y}}); } else if (board[x-1][y] != '.'){ q.push_back({score-1, {x-1, y}}); ans = max(ans, 1-score); } } if (y != 0 && !board2[x][y-1]){ board2[x][y-1] = 1; if (board[x][y-1] == board[x][y]){ q.push_front({score, {x, y-1}}); } else if (board[x][y-1] != '.'){ q.push_back({score-1, {x, y-1}}); ans = max(ans, 1-score); } } if (y != m - 1 && !board2[x][y+1]){ board2[x][y+1] = 1; if (board[x][y+1] == board[x][y]){ q.push_front({score, {x, y+1}}); } else if (board[x][y+1] != '.'){ q.push_back({score-1, {x, y+1}}); ans = max(ans, 1-score); } } if (x != n-1 && !board2[x+1][y]){ board2[x+1][y] = 1; if (board[x+1][y] == board[x][y]){ q.push_front({score, {x+1, y}}); } else if (board[x+1][y] != '.'){ q.push_back({score-1, {x+1, y}}); ans = max(ans, 1-score); } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...