제출 #430606

#제출 시각아이디문제언어결과실행 시간메모리
430606asbsfds전선 연결 (IOI17_wiring)C++14
7 / 100
54 ms8052 KiB
#include "wiring.h"
#include <vector>
typedef long long llint;

const int maxn = 410;

llint dp[maxn][maxn];
llint min(llint a, llint b) {
	if (a < b) return a;
	return b;
}

llint abs(llint x) {
	if (x < 0) return -x;
	return x;
}

long long min_total_length(std::vector<int> r, std::vector<int> b) {
	for (int i = 0; i < r.size(); i++) 
		for (int j = 0; j < b.size(); j++) 
			dp[i][j] = (1LL << 60);
			
	dp[0][0] = abs(r[0] - b[0]);
	for (int i = 0; i < r.size(); i++) {
		for (int j = 0; j < b.size(); j++) {
			llint dis = abs(r[i] - b[j]);
			if (i > 0) dp[i][j] = min(dp[i - 1][j] + dis, dp[i][j]);
			if (j > 0) dp[i][j] = min(dp[i][j - 1] + dis, dp[i][j]);
			if (i > 0 && j > 0) dp[i][j] = min(dp[i - 1][j - 1] + dis, dp[i][j]);
		}
	}
	
	/**
	for (int i = 0; i < r.size(); i++) {
		for (int j = 0; j < b.size(); j++) {
			printf("%d ", dp[i][j]);
		}
		printf("\n");
	}
	**/
	return dp[r.size() - 1][b.size() - 1];
}

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |  for (int i = 0; i < r.size(); i++)
      |                  ~~^~~~~~~~~~
wiring.cpp:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int j = 0; j < b.size(); j++)
      |                   ~~^~~~~~~~~~
wiring.cpp:24:20: 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 < r.size(); i++) {
      |                  ~~^~~~~~~~~~
wiring.cpp:25:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for (int j = 0; j < b.size(); j++) {
      |                   ~~^~~~~~~~~~
#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...