제출 #1095215

#제출 시각아이디문제언어결과실행 시간메모리
1095215InvMODTracks in the Snow (BOI13_tracks)C++14
100 / 100
906 ms152268 KiB
#include<bits/stdc++.h> using namespace std; const int dx[4] = {1, -1, 0, 0}; const int dy[4] = {0, 0, -1, 1}; void solve() { int n,m; cin >> n >> m; vector<vector<int>> a(n, vector<int>(m)); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ char c; cin >> c; a[i][j] = (c != '.' ? (c == 'F' ? 1 : 2) : 0); } } vector<vector<int>> mx_dif(n, vector<int>(m)); function<bool(int,int)> init = [&](int x, int y){ return x >= 0 && x < n && y >= 0 && y < m && a[x][y] != 0 && !mx_dif[x][y]; }; function<int(int,int)> id = [&](int x, int y){ return x*m + y; }; deque<int> dq; dq.push_back(0); mx_dif[0][0] = 1; while(!dq.empty()){ int cur_id = dq.front(); dq.pop_front(); int y = cur_id % m; int x = (cur_id - y) / m; for(int i = 0; i < 4; i++){ int xx = dx[i] + x; int yy = dy[i] + y; if(init(xx, yy) && !mx_dif[xx][yy]){ if(a[xx][yy] != a[x][y]){ mx_dif[xx][yy] = mx_dif[x][y] + 1; dq.push_back(id(xx, yy)); } else{ mx_dif[xx][yy] = mx_dif[x][y]; dq.push_front(id(xx, yy)); } } } } int answer = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ answer = max(answer, mx_dif[i][j]); } } cout << answer <<"\n"; } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "InvMOD" if(fopen(name".INP", "r")){ freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); } solve(); return 0; }

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

tracks.cpp: In function 'int32_t main()':
tracks.cpp:70:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |         freopen(name".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(name".OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...