제출 #654211

#제출 시각아이디문제언어결과실행 시간메모리
654211Ronin13전선 연결 (IOI17_wiring)C++14
7 / 100
22 ms3756 KiB
#include "wiring.h"
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;

long long min_total_length(std::vector<int> r, std::vector<int> b) {
    if(r.size() > 2000 || b.size() > 2000){
        if(r.size() < b.size()){
            ll ans = 0;
            for(int i = 0; i < b.size(); i++){
                ans += b[i] - r[max((int)r.size() - 1,i)];
            }
            return ans;
        }
        swap(r, b);
        for(int i = 0; i< r.size(); i++) r[i] = -r[i];
        for(int i = 0; i < b.size(); i++) b[i] = -b[i];
        ll ans = 0;
            for(int i = 0; i < b.size(); i++){
                ans += b[i] - r[max((int)r.size() - 1,i)];
            }
            return ans;
    }
    int n = r.size(), m = b.size();
    ll dp[n + 1][m + 1];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            dp[i][j] = 1e18;
        }
    }
    dp[0][0] = 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 - 1] - b[j - 1]);
        }
    }
	return dp[n][m];;
}

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:17:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |             for(int i = 0; i < b.size(); i++){
      |                            ~~^~~~~~~~~~
wiring.cpp:23:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int i = 0; i< r.size(); i++) r[i] = -r[i];
      |                        ~^~~~~~~~~~
wiring.cpp:24:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int i = 0; i < b.size(); i++) b[i] = -b[i];
      |                        ~~^~~~~~~~~~
wiring.cpp:26:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             for(int i = 0; i < b.size(); i++){
      |                            ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...