제출 #675786

#제출 시각아이디문제언어결과실행 시간메모리
675786NONTACTracks in the Snow (BOI13_tracks)C++11
0 / 100
1420 ms239576 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; int dx[4] = {0, 0, 1, -1}; int dy[4] = {1, -1, 0, 0}; int n, m; char grid[4002][4002]; int d[4002][4002]; int ans = 0; bool same(char c1, char c2) { if(c1 != c2) return true; return false; } int bfs(int si, int sj) { deque<ii> dq; d[si][sj] = 1; dq.push_front(ii(si, sj)); while(!dq.empty()){ int ui = dq.front().first, uj = dq.front().second; dq.pop_front(); ans = max(ans, d[ui][uj]); for(int i = 0; i < 4; i++){ int vi = ui + dx[i], vj = uj + dy[i]; int w = same(grid[ui][uj], grid[vi][vj]); if(vi < 1 || vi > n || vj < 1 || vj > m) continue; if(d[vi][vj] == 0 && grid[vi][vj] != '.'){ d[vi][vj] = d[ui][uj] + w; if(w == 0){ dq.push_front(ii(vi, vj)); } else{ dq.push_back(ii(vi, vj)); } } } } } int main() { //freopen("test.in","r",stdin); //freopen("test.out","w",stdout); cin>>n>>m; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ cin>>grid[i][j]; } } bfs(1, 1); cout<<ans; return 0; }

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

tracks.cpp: In function 'int bfs(int, int)':
tracks.cpp:43:1: warning: no return statement in function returning non-void [-Wreturn-type]
   43 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...