제출 #1035815

#제출 시각아이디문제언어결과실행 시간메모리
1035815mindiyak전선 연결 (IOI17_wiring)C++14
컴파일 에러
0 ms0 KiB
#include "wiring.h" #pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> #include <string> #include <iostream> #include <cmath> #include <numeric> #include <limits> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<int, int> pi; typedef pair<int, int> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<vector<int>> vvi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<vector<ll>> vvl; typedef vector<pi> vpi; typedef vector<pl> vpl; #define FOR(i, a, b) for (int i = a; i < (b); i++) // #define F0R(i, a) for (int i = 0; i < (a); i++) #define FORd(i, a, b) for (int i = (b)-1; i >= a; i--) #define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define uid(a, b) uniform_int_distribution<int>(a, b)(rng) #define len(x) (int)(x).size() #define mp make_pair #define pb push_back #define F first #define nl endl #define S second #define lb lower_bound #define ub upper_bound #define aint(x) x.begin(), x.end() #define raint(x) x.rbegin(), x.rend() #define ins insert const int MOD = 1000000007; long long min_total_length(vi r, vi b) { int n = r.size(), m = b.size(); vvi dp(m,vi(n,INT_MAX)); ll ans = 0; dp[0][0] = abs(r[0]-b[0]); FOR(i,1,m){ dp[i][0] = dp[i-1][0] + abs(r[0]-b[i]); } vi min_dist(n,INT_MAX); FOR(i,0,n){ FOR(j,0,m){ min_dist[i] = min(min_dist[i],ll(abs(r[i]-b[j]))); } } // FOR(i,0,n)cout << min_dist[i] << " "; // cout << endl; FOR(i,1,n){ dp[0][i] = dp[0][i-1]+min_dist[i]; FOR(j,1,m){ dp[j][i] = min(dp[j][i],dp[j][i-1] + min_dist[i]); dp[j][i] = min(dp[j][i],dp[j-1][i] + abs(r[i]-b[j])); dp[j][i] = min(dp[j][i],dp[j-1][i-1] + abs(r[i]-b[j])); } } // cout << endl; // FOR(i,0,m){ // FOR(j,0,n){ // cout << dp[i][j] << " "; // }cout << endl; // } return dp[m-1][n-1]; }

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

wiring.cpp: In function 'long long int min_total_length(vi, vi)':
wiring.cpp:58:52: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, ll)'
   58 |    min_dist[i] = min(min_dist[i],ll(abs(r[i]-b[j])));
      |                                                    ^
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:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
wiring.cpp:58:52: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   58 |    min_dist[i] = min(min_dist[i],ll(abs(r[i]-b[j])));
      |                                                    ^
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:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
wiring.cpp:58:52: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   58 |    min_dist[i] = min(min_dist[i],ll(abs(r[i]-b[j])));
      |                                                    ^
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:3:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
wiring.cpp:58:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |    min_dist[i] = min(min_dist[i],ll(abs(r[i]-b[j])));
      |                                                    ^
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:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
wiring.cpp:58:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   58 |    min_dist[i] = min(min_dist[i],ll(abs(r[i]-b[j])));
      |                                                    ^
wiring.cpp:46:5: warning: unused variable 'ans' [-Wunused-variable]
   46 |  ll ans = 0;
      |     ^~~