Submission #389896

#TimeUsernameProblemLanguageResultExecution timeMemory
389896null_aweTracks in the Snow (BOI13_tracks)C++14
2.19 / 100
456 ms125952 KiB
#include <bits/stdc++.h> using namespace std; int main() { int h, w; cin >> h >> w; vector<vector<int>> field(h, vector<int>(w, 0)), filled(h, vector<int>(w, 0)); for (int i = 0; i < h; ++i) { string line; cin >> line; for (int j = 0; j < w; ++j) field[i][j] = (line[j] == '.' ? -1 : (line[j] == 'R' ? 1 : 2)); } int r = 0; vector<vector<int>> next; vector<int> first{0, 0}; next.push_back(first); while (!next.empty()) { queue<vector<int>> q; for (vector<int> go : next) q.push(go); next.clear(); while (!q.empty()) { vector<int> square = q.front(); q.pop(); for (int a = -1; a < 2; a += 2) { // int newX = square[0] + a, newY = square[1]; // if (newX < 0 || newY < 0 || newX >= h || newY >= w) continue; // if (filled[newX][newY] > 0 || field[newX][newY] < 0) continue; // vector<int> add{newX, newY}; // if (field[newX][newY] == field[square[0]][square[1]]) q.push(add); // else next.push_back(add); } for (int a = -1; a < 2; a += 2) { // int newX = square[0], newY = square[1] + a; // if (newX < 0 || newY < 0 || newX >= h || newY >= w) continue; // if (filled[newX][newY] > 0 || field[newX][newY] < 0) continue; // vector<int> add{newX, newY}; // if (field[newX][newY] == field[square[0]][square[1]]) q.push(add); // else next.push_back(add); } // filled[square[0]][square[1]] = 1; } r++; } cout << r; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...