제출 #1107186

#제출 시각아이디문제언어결과실행 시간메모리
1107186danielsuhTracks in the Snow (BOI13_tracks)C++17
24.38 / 100
2165 ms1048576 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; vector<int> dx = {1, -1, 0, 0}; vector<int> dy = {0, 0, 1, -1}; void floodfill(vector<string>& grid, vector<vector<bool>>& visited, int i, int j, char current_animal) { if(i < 0 || j < 0 || i >= grid.size() || j >= grid[0].size()) return; if(grid[i][j] != current_animal && grid[i][j] != '#') return; if(visited[i][j]) return; visited[i][j] = true; grid[i][j] = (current_animal == 'R' ? 'F' : 'R'); for(int k = 0; k < 4; k++) { floodfill(grid, visited, i + dx[k], j + dy[k], current_animal); } } void print(vector<string>& grid) { for(int i = 0; i < grid.size(); i++) { for(int j = 0; j < grid[0].size(); j++) { cout << grid[i][j]; } cout << "\n"; } cout << "\n"; } int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M; cin >> N >> M; vector<string> grid(N); for(auto &x : grid) cin >> x; vector<vector<bool>> visited(N, vector<bool>(N, false)); int sum = 0; while(true) { fill(visited.begin(), visited.end(), vector<bool>(N, false)); sum++; floodfill(grid, visited, 0, 0, grid[0][0]); /*print(grid);*/ bool foundF = false; bool foundR = false; for(int i = 0; i < N; i++) { for(int j = 0; j < M; j++) { foundF |= (grid[i][j] == 'F'); foundR |= (grid[i][j] == 'R'); } } if(foundF ^ foundR) { break; } } cout << sum + 1 << endl; }

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp: In function 'void floodfill(std::vector<std::__cxx11::basic_string<char> >&, std::vector<std::vector<bool> >&, int, int, char)':
tracks.cpp:10:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  if(i < 0 || j < 0 || i >= grid.size() || j >= grid[0].size()) return;
      |                       ~~^~~~~~~~~~~~~~
tracks.cpp:10:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |  if(i < 0 || j < 0 || i >= grid.size() || j >= grid[0].size()) return;
      |                                           ~~^~~~~~~~~~~~~~~~~
tracks.cpp: In function 'void print(std::vector<std::__cxx11::basic_string<char> >&)':
tracks.cpp:23:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i = 0; i < grid.size(); i++) {
      |                 ~~^~~~~~~~~~~~~
tracks.cpp:24:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for(int j = 0; j < grid[0].size(); j++) {
      |                  ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...