제출 #842508

#제출 시각아이디문제언어결과실행 시간메모리
842508saturinaTracks in the Snow (BOI13_tracks)C++14
100 / 100
548 ms241232 KiB
//made by Nguyễn Hồng Nam #include <bits/stdc++.h> using namespace std; #define ll long long #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") const ll mod = 1e9 + 7,inf = 1e18,mxn = 4005; #define pll pair<ll,ll> #define fi first #define se second deque<pll> q; ll d[mxn][mxn],h,w,row[4] = {-1,0,0,1},col[4] = {0,-1,1,0},ans = 1; string s[mxn]; void maxz(ll &a,ll b) { if(a < b) a= b; } bool check(ll i,ll j) { if(i >= 0 && i < h && j >= 0 && j < w && s[i][j] != '.') return true; return false; } void bfs01() { d[0][0] = 1; q.push_back({0,0}); while(!q.empty()) { pll mx = q.front(); maxz(ans,d[mx.fi][mx.se]); q.pop_front(); for(ll i = 0; i < 4; i++) { ll a = mx.fi + row[i],b = mx.se + col[i]; if(check(a,b) && d[a][b] == 0) { if(s[a][b] == s[mx.fi][mx.se]) { d[a][b] = d[mx.fi][mx.se]; q.push_front({a,b}); } else { d[a][b] = d[mx.fi][mx.se] + 1; q.push_back({a,b}); } } } } } int main() { #define taskname "track" if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); cin >> h >> w; for(ll i = 0; i < h; i++) { cin >> s[i]; } bfs01(); cout << ans << '\n'; return 0; }

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

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