Submission #1025590

#TimeUsernameProblemLanguageResultExecution timeMemory
1025590amirhoseinfar1385전선 연결 (IOI17_wiring)C++17
Compilation error
0 ms0 KiB
#include "wiring.h"
#include<bits/stdc++.h>
using namespace std;
const long long maxn=200000+10;
long long dp[maxn],inf=1e16,vas[maxn];
long long n,m;
vector<long long>allind;

long long min_total_length(std::vector<int> r, std::vector<int> b) {
	n=(long long)r.size();
	m=(long long)b.size();
	allind.push_back(-1);
	for(auto x:r){
		allind.push_back(x);
	}
	for(auto x:b){
		allind.push_back(x);
	}
	sort(allind.begin(),allind.end());
	allind.resize(unique(allind.begin(),allind.end())-allind.begin());
	for(long long i=0;i<n;i++){
		r[i]=lower_bound(allind.begin(),allind.end(),r[i])-allind.begin();
		vas[r[i]]=1;
	}
	for(long long i=0;i<m;i++){
		b[i]=lower_bound(allind.begin(),allind.end(),b[i])-allind.begin();
		vas[b[i]]=2;
	}
	for(long long i=1;i<maxn;i++){
		dp[i]=inf;
	}
	dp[0]=0;
	long long sz=(long long)allind.size();
	for(long long i=1;i<sz;i++){
		long long av=allind[i],unnow=0,last=i,bar=0,akh;
		for(long long j=i-1;j>=1;j--){
			if(vas[j]==vas[i]&&vas[j]!=vas[j+1]){
				break;
			}
			if(vas[j]==vas[i]){
				last=j;
				unnow+=av;
				av=allind[j];
			}else{
				bar+=allind[j];
				akh=allind[last-1];
				long long ted1=i-last+1;
				long long ted2=(last-1)-j+1;
				dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
			}
		}
	}
	return dp[sz-1];
}

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:49:62: error: no matching function for call to 'max(int, long long int)'
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                              ^
In file included from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
wiring.cpp:49:62: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                              ^
In file included from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
wiring.cpp:49:62: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
wiring.cpp:49:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                              ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
wiring.cpp:49:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                              ^
wiring.cpp:49:84: error: no matching function for call to 'max(int, long long int)'
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                                                    ^
In file included from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
wiring.cpp:49:84: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                                                    ^
In file included from /usr/include/c++/10/vector:60,
                 from wiring.h:1,
                 from wiring.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
wiring.cpp:49:84: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
wiring.cpp:49:84: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                                                    ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from wiring.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
wiring.cpp:49:84: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   49 |     dp[i]=min(dp[i],dp[j-1]+unnow-(bar-akh)+max(1,ted2-ted1+1)*av-max(1,ted1-ted2+1)*akh);
      |                                                                                    ^