제출 #1320200

#제출 시각아이디문제언어결과실행 시간메모리
1320200kasamchi전선 연결 (IOI17_wiring)C++20
컴파일 에러
0 ms0 KiB
#include "wiring.h" #include <vector> using namespace std; long long min_total_length(vector<int> r, vector<int> b) { int n = r.size(), m = b.size(); vector<vector<long long>> dp(n, vector(m, 0LL)); dp[0][0] = abs(r[0] - b[0]); for (int i = 1; i < n; i++) { dp[i][0] = dp[i - 1][0] + abs(r[i] - b[0]); } for (int j = 1; j < m; j++) { dp[0][j] = dp[0][j - 1] + abs(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 - 1], min(dp[i - 1][j], dp[i][j - 1])) + abs(a[i] - b[j]); } } 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:8:20: error: 'abs' was not declared in this scope
    8 |         dp[0][0] = abs(r[0] - b[0]);
      |                    ^~~
wiring.cpp:17:97: error: 'a' was not declared in this scope
   17 |                         dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + abs(a[i] - b[j]);
      |                                                                                                 ^