Submission #552523

#TimeUsernameProblemLanguageResultExecution timeMemory
552523timreizin전선 연결 (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include "wiring.h"
#include <vector>

using namespace std;

using ll = long long;

ll min_total_length(vector<int> r, vector<int> b)
{
    vector<vector<ll>> dp(r.size(), vector<ll>(b.size()));
    for (int i = 0; i < b.size(); ++i)
    {
        dp[0][i] = abs(r[0] - b[i]);
        if (i != 0) dp[0][i] = dp[0][i - 1];
    }
    for (int i = 1; i < r.size(); ++i)
    {
        for (int j = 0; j < b.size(); ++j)
        {
            dp[i][j] = dp[i - 1][j] + abs(r[i] - b[j]);
            ll sum = 0;
            for (int k = j - 1; k >= 0; --k)
            {
                sum += abs(r[i] - b[k + 1]);
                dp[i][j] = min(dp[i][j], dp[i - 1][k] + sum);
            }
        }
    }
	return dp.back().back();
}

Compilation message (stderr)

wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i = 0; i < b.size(); ++i)
      |                     ~~^~~~~~~~~~
wiring.cpp:13:20: error: 'abs' was not declared in this scope
   13 |         dp[0][i] = abs(r[0] - b[i]);
      |                    ^~~
wiring.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int i = 1; i < r.size(); ++i)
      |                     ~~^~~~~~~~~~
wiring.cpp:18:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for (int j = 0; j < b.size(); ++j)
      |                         ~~^~~~~~~~~~
wiring.cpp:20:39: error: 'abs' was not declared in this scope
   20 |             dp[i][j] = dp[i - 1][j] + abs(r[i] - b[j]);
      |                                       ^~~