제출 #675777

#제출 시각아이디문제언어결과실행 시간메모리
675777NONTACTracks in the Snow (BOI13_tracks)C++11
0 / 100
1 ms212 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]; bool vis[4002][4002]; void bfs(int si, int sj, char c) { queue<ii> q; vis[si][sj] = true; q.push(ii(si, sj)); while(!q.empty()){ int ui = q.front().first, uj = q.front().second; q.pop(); for(int i = 0; i < 4; i++){ int vi = ui + dx[i], vj = uj + dy[i]; if(!vis[vi][vj]){ if(grid[vi][vj] == grid[ui][uj]){ vis[vi][vj] = true; q.push(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]; } int fox = 0, rab = 0; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(grid[i][j] == 'F'){ if(!vis[i][j]){ fox++; bfs(i, j, 'F'); } } } } for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ if(grid[i][j] == 'R'){ if(!vis[i][j]){ rab++; bfs(i, j, 'R'); } } } } cout<<min(rab, fox) + 1; return 0; }

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

tracks.cpp: In function 'int main()':
tracks.cpp:35:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |     freopen("test.in","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
tracks.cpp:36:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     freopen("test.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...