제출 #895216

#제출 시각아이디문제언어결과실행 시간메모리
895216nightfalWiring (IOI17_wiring)C++14
컴파일 에러
0 ms0 KiB
#include "wiring.h" #include <stdlib.h> #include <math.h> long long min_total_length(std::vector<int> r, std::vector<int> b) { int n = r.size(), m = b.size(); long long dp[n][m]; dp[0][0] = r[0]>b[0]? r[0]-b[0]:b[0]-r[0]; for(int i=0; i<n; i++) dp[i][0] = dp[i-1][0] + r[i]>b[0]? r[i]-b[0]:b[0]-r[i]; for(int j=0; j<m; j++) dp[0][j] = dp[0][j-1] + r[0]>b[j]? r[0]-b[j]:b[j]-r[0]; for(int i=1; i<n; i++) for(int j=1; j<m; j++) dp[i][j] = min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1]) + abs(r[i]-b[i]); return dp[n-1][m-1]; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:15:20: error: 'min' was not declared in this scope; did you mean 'std::min'?
   15 |         dp[i][j] = min(dp[i-1][j],dp[i][j-1],dp[i-1][j-1]) + abs(r[i]-b[i]);
      |                    ^~~
      |                    std::min
In file included from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: 'std::min' declared here
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
wiring.cpp:14:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   14 |       for(int j=1; j<m; j++)
      |       ^~~
wiring.cpp:16:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   16 |  return dp[n-1][m-1];
      |  ^~~~~~