답안 #43868

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43868 2018-03-26T04:41:54 Z faustaadp 전선 연결 (IOI17_wiring) C++14
0 / 100
85 ms 4252 KB
#include "wiring.h"
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll i,A[101010],B[101010],SA,SB,d[202][202];
ll hey(ll aa,ll bb,ll cc)
{
	ll ii,h=0;
	for(ii=bb;ii<=cc;ii++)
		h+=abs(A[aa]-B[ii]);
	return h;
}
ll depe(ll aa,ll bb)
{
	if(aa==SA+1&&bb==SB+1)
		return 0;
	if(aa==SA+1||bb==SB+1)
		return 1e18;
	if(d[aa][bb]==-1)
	{
		d[aa][bb]=1e18;
		ll ii;
		for(ii=bb;ii<=SB;ii++)
			d[aa][bb]=min(d[aa][bb],hey(aa,bb,ii)+depe(aa+1,ii+1));
	}
	return d[aa][bb];
}
long long min_total_length(std::vector<int> r, std::vector<int> b) {
	if(r.size()<b.size())
	{
		for(i=0;i<r.size();i++)
			A[i+1]=r[i];
		for(i=0;i<b.size();i++)
			B[i+1]=b[i];
	}
	else
	{
		for(i=0;i<r.size();i++)
			B[i+1]=r[i];
		for(i=0;i<b.size();i++)
			A[i+1]=b[i];
	}
	SA=min(r.size(),b.size());
	SB=max(r.size(),b.size());
	if(r.size()<=200&&b.size()<=200)
	{
		memset(d,-1,sizeof(d));
		return depe(1,1);
	}
	return 0;
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:35:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(i=0;i<r.size();i++)
            ^
wiring.cpp:37:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(i=0;i<b.size();i++)
            ^
wiring.cpp:42:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(i=0;i<r.size();i++)
            ^
wiring.cpp:44:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(i=0;i<b.size();i++)
            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Incorrect 2 ms 740 KB 3rd lines differ - on the 1st token, expected: '14340', found: '17422'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 844 KB Output is correct
2 Correct 85 ms 904 KB Output is correct
3 Incorrect 27 ms 4252 KB 3rd lines differ - on the 1st token, expected: '41596985758595', found: '0'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4252 KB Output is correct
2 Incorrect 2 ms 4252 KB 3rd lines differ - on the 1st token, expected: '17703', found: '19052'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4252 KB 3rd lines differ - on the 1st token, expected: '27', found: '30'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Incorrect 2 ms 740 KB 3rd lines differ - on the 1st token, expected: '14340', found: '17422'
3 Halted 0 ms 0 KB -