제출 #344195

#제출 시각아이디문제언어결과실행 시간메모리
344195ak2006Tracks in the Snow (BOI13_tracks)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vc = vector<char>; using vvc = vector<vc>; const ll mod = 1e9 + 7,inf = 1e18; const vi dx = {1,-1,0,0},dy = {0,0,1,-1}; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int main() { fast; int w,h; cin>>w>>h; vvc g(w,vc(h)); for (int i = 0;i<w;i++)for (int j = 0;j<h;j++)cin>>g[i][j]; vvi dp(w,vi(h,1e9)); dp[0][0] = 0; priority_queue<vi>q; q.push({0,0,0}); int ans = 0; while (!q.empty()){ int ci = q.top()[1],cj = q.top()[2]; q.pop(); for (int x = 0;x<4;x++){ int ni = ci + dx[x],nj = cj + dy[x]; if (ni < 0 || nj < 0 || ni >= w || nj >= h || g[ni][nj] == '.')continue; int cost = (g[ci][cj] == g[ni][nj] ? 0 : 1); if (dp[ni][nj] <= dp[ci][cj] + cost)continue; dp[ni][nj] = dp[ci][cj] + cost; ans = max(ans,dp[i][j]); q.push({-dp[ni][nj],ni,nj}); } } cout<<ans + 1; return 0; }

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

tracks.cpp: In function 'int main()':
tracks.cpp:34:30: error: 'i' was not declared in this scope; did you mean 'ni'?
   34 |             ans = max(ans,dp[i][j]);
      |                              ^
      |                              ni
tracks.cpp:34:33: error: 'j' was not declared in this scope; did you mean 'nj'?
   34 |             ans = max(ans,dp[i][j]);
      |                                 ^
      |                                 nj