제출 #390785

#제출 시각아이디문제언어결과실행 시간메모리
390785alishahali1382전선 연결 (IOI17_wiring)C++14
7 / 100
1094 ms3656 KiB
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()

const int inf=1000000100;
const int MAXN=100010;

int n, m, k;
ll dp[205][205];
ll X[MAXN], Y[MAXN];

ll min_total_length(vector<int> R, vector<int> B){
	memset(dp, 63, sizeof(dp));
	memset(X, 63, sizeof(X));
	memset(Y, 63, sizeof(Y));
	for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
		ll d=abs(R[i-1]-B[j-1]);
		X[i]=min(X[i], d);
		Y[j]=min(Y[j], d);
	}
	dp[0][0]=0;
	for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
		ll d=abs(R[i-1]-B[j-1]);
		// dp[i][j]=min({dp[i-1][j], dp[i][j-1], dp[i-1][j-1]}) + d;
		dp[i][j]=min(dp[i-1][j]+X[i], dp[i][j-1]+Y[j]);
		dp[i][j]=min(dp[i][j], dp[i-1][j-1]+d);
	}
	return dp[R.size()][B.size()];
}

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

wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:24:17: 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=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
      |                ~^~~~~~~~~~
wiring.cpp:24:49: 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=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
      |                                                ~^~~~~~~~~~
wiring.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i=1; i<=R.size(); i++) for (int j=1; j<=B.size(); j++){
      |                ~^~~~~~~~~~
wiring.cpp:30:49: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |  for (int i=1; i<=R.size(); i++) for (int j=1; 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...