제출 #1062359

#제출 시각아이디문제언어결과실행 시간메모리
1062359danielzhuTracks in the Snow (BOI13_tracks)C++17
100 / 100
556 ms26084 KiB
#include <bits/stdc++.h> using namespace std; int H, W; char grid[4001][4001]; vector<pair<int,int>> dir = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; void bfs(queue<pair<int,int>> &from, queue<pair<int,int>> &to, char cc){ while(!from.empty()){ auto temp = from.front(); from.pop(); //grid[temp.first][temp.second] = '.'; int x = temp.first, y = temp.second; for(auto [dx, dy] : dir){ if(x+dx > -1 && x+dx < H && y+dy > -1 && y+dy < W && grid[x+dx][y+dy] != '.'){ if(grid[x+dx][y+dy] != cc) to.push({x+dx, y+dy}); else from.push({x+dx, y+dy}); grid[x+dx][y+dy] = '.'; } } } } int main(){ cin>>H>>W; for(int i = 0; i < H; i++){ string s; cin>>s; for(int j = 0; j < W; j++){ grid[i][j] = s[j]; } } int x = 0, y = 0, ans = 0; char cc = grid[0][0]; queue<pair<int,int>> F, R; if(cc == 'F') F.push({0,0}); else R.push({0,0}); grid[0][0] = '.'; while(true){ if(cc == 'F' && F.empty()) break; if(cc == 'R' && R.empty()) break; if(cc == 'F') bfs(F, R, cc); else if(cc == 'R') bfs(R, F, cc); ans++; if(cc == 'F') cc = 'R'; else if(cc == 'R') cc = 'F'; } cout<<ans<<endl; return 0; }

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

tracks.cpp: In function 'int main()':
tracks.cpp:31:6: warning: unused variable 'x' [-Wunused-variable]
   31 |  int x = 0, y = 0, ans = 0;
      |      ^
tracks.cpp:31:13: warning: unused variable 'y' [-Wunused-variable]
   31 |  int x = 0, y = 0, ans = 0;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...