Submission #1011130

#TimeUsernameProblemLanguageResultExecution timeMemory
1011130Roman70전선 연결 (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;

typedef long long int64_t;

int64_t min_total_length(vector<int>& red, vector<int>& blue) {
    int n = red.size();
    int m = blue.size();

    // DP table initialized to large values
    vector<vector<int64_t>> dp(n + 1, vector<int64_t>(m + 1, numeric_limits<int64_t>::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(red[i-1] - blue[j-1]));
            }
            if (i > 0) {
                dp[i][j] = min(dp[i][j], dp[i-1][j] + abs(red[i-1] - blue[j-1]));
            }
            if (j > 0) {
                dp[i][j] = min(dp[i][j], dp[i][j-1] + abs(red[i-1] - blue[j-1]));
            }
        }
    }

    return dp[n][m];
}

Compilation message (stderr)

wiring.cpp:8:19: error: conflicting declaration 'typedef long long int int64_t'
    8 | typedef long long 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:2:
/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;
      |                   ^~~~~~~