제출 #1011129

#제출 시각아이디문제언어결과실행 시간메모리
1011129Roman70전선 연결 (IOI17_wiring)C++17
컴파일 에러
0 ms0 KiB
#include <algorithm> #include <cmath> using namespace std; typedef long long int int64_t; int64_t min_total_length(int r[], int b[], int n, int m) { // DP table initialized to large values int64_t dp[n + 1][m + 1]; for (int i = 0; i <= n; ++i) { for (int j = 0; j <= m; ++j) { dp[i][j] = LLONG_MAX; } } // Base case: no points, no wires dp[0][0] = 0; // Fill the DP table for (int i = 0; i <= n; ++i) { for (int j = 0; j <= m; ++j) { if (i > 0 && j > 0) { dp[i][j] = min(dp[i][j], dp[i-1][j-1] + abs(r[i-1] - b[j-1])); } if (i > 0) { dp[i][j] = min(dp[i][j], dp[i-1][j] + abs(r[i-1] - b[j-1])); } if (j > 0) { dp[i][j] = min(dp[i][j], dp[i][j-1] + abs(r[i-1] - b[j-1])); } } } return dp[n][m]; }

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

wiring.cpp:6:23: error: conflicting declaration 'typedef long long int int64_t'
    6 | typedef long long int int64_t;
      |                       ^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:155,
                 from /usr/include/stdlib.h:394,
                 from /usr/include/c++/10/cstdlib:75,
                 from /usr/include/c++/10/bits/stl_algo.h:59,
                 from /usr/include/c++/10/algorithm:62,
                 from wiring.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: previous declaration as 'typedef __int64_t int64_t'
   27 | typedef __int64_t int64_t;
      |                   ^~~~~~~
wiring.cpp: In function 'int64_t min_total_length(int*, int*, int, int)':
wiring.cpp:13:24: error: 'LLONG_MAX' was not declared in this scope
   13 |             dp[i][j] = LLONG_MAX;
      |                        ^~~~~~~~~
wiring.cpp:3:1: note: 'LLONG_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
    2 | #include <cmath>
  +++ |+#include <climits>
    3 |