제출 #430730

#제출 시각아이디문제언어결과실행 시간메모리
430730Belgutei전선 연결 (IOI17_wiring)C++17
20 / 100
37 ms4036 KiB
#include "wiring.h"
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ff first
#define ss second
#define mk make_pair
#define pb push_back

long long min_total_length(std::vector<int> r, std::vector<int> b) {
	ll cc=0;
	for(int i=0; i<b.size(); i++){
		if(b[i]<=r[r.size()-1]) cc=1;
	}
	if(cc==0){
		// subtask 3
		long long ans=0;
		if(r.size()>=b.size()){
			for(int i=0; i<b.size(); i++){
				ans+=b[i]-r[i];
			}
			for(int i=b.size(); i<r.size(); i++){
				ans+=b[0]-r[i];
			}
			return ans;
		}
		else{
			for(int i=0; i<r.size(); i++){
				ans+=b[i]-r[i];
			}
			for(int i=r.size(); i<b.size(); i++){
				ans+=b[i]-r[r.size()-1];
			}
			return ans;
		}
	}
	if(r.size()<=200 && b.size()<=200){
		// subtask1
		ll dp[205][205];
		// dp[i][j] first i of red and first j of blue
		for(int i=0; i<r.size(); i++){
			for(int j=0; j<b.size(); j++){
				ll mn=1e18;
				if(i-1>=0) mn=min(mn,dp[i-1][j]);
				if(j-1>=0) mn=min(mn,dp[i][j-1]);
				if(i-1>=0 && j-1>=0) mn=min(mn,dp[i-1][j-1]);
				if(mn==1e18) dp[i][j]=abs(r[i]-b[j]);
				else dp[i][j]=mn+abs(r[i]-b[j]);
			}
		}
		return dp[r.size()-1][b.size()-1];
	}
	return 0;
}

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

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