# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1016963 | 2024-07-08T16:31:35 Z | TroySer | Palembang Bridges (APIO15_bridge) | C++17 | 컴파일 오류 |
0 ms | 0 KB |
// median? #include <bits/stdc++.h> using namespace std; const long long int INF = 1e18; long long int K, N; long long int build1, build2; char zone1, zone2; long long int Dmin = 0; struct Place { char zone; long long int building; }; vector<pair<Place, Place> > people; vector<Place> person; long long int cost(long long int currK) { long long int currMin = 0; for (int j = 0; j < people.size(); j++) { currMin += abs(people[j].first.building - currK); currMin++; currMin += abs(people[j].second.building - currK); } return currMin; } int main() { cin >> K >> N; for (int i = 0; i < N; i++) { cin >> zone1 >> build1 >> zone2 >> build2; if (zone1 == zone2) { Dmin += abs(build2 - build1); } else { people.push_back(make_pair( (Place){zone1, build1}, (Place){zone2, build2} )); person.push_back((Place){build1}); person.push_back((Place){build2}); } } int M = person.size(); long long int possibleMin = INF; if (M == 0) possibleMin = 0; else { sort(person.begin(), person.end()); for (int i = M/2; i <= M/2 + 1; i++) { possibleMin = min(possibleMin, cost(person[i].building)); } } cout << possibleMin + Dmin << "\n"; }
Compilation message
bridge.cpp: In function 'long long int cost(long long int)': bridge.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<Place, Place> >::size_type' {aka 'long unsigned int'} [-Wsign-compare] 24 | for (int j = 0; j < people.size(); j++) { | ~~^~~~~~~~~~~~~~~ bridge.cpp: In function 'int main()': bridge.cpp:43:38: warning: narrowing conversion of 'build1' from 'long long int' to 'char' [-Wnarrowing] 43 | person.push_back((Place){build1}); | ^~~~~~ bridge.cpp:44:38: warning: narrowing conversion of 'build2' from 'long long int' to 'char' [-Wnarrowing] 44 | person.push_back((Place){build2}); | ^~~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Iterator2 = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >]': /usr/include/c++/10/bits/stl_algo.h:82:17: required from 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1924:34: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1958:38: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1974:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:4859:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >]' bridge.cpp:53:42: required from here /usr/include/c++/10/bits/predefined_ops.h:43:23: error: no match for 'operator<' (operand types are 'Place' and 'Place') 43 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/stl_iterator.h:1096:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)' 1096 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1096:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/predefined_ops.h:43:23: note: 'Place' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 43 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/stl_iterator.h:1104:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)' 1104 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1104:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/predefined_ops.h:43:23: note: 'Place' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 43 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = Place; _Iterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >]': /usr/include/c++/10/bits/stl_algo.h:1826:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Val_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1854:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1886:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1977:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:4859:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >]' bridge.cpp:53:42: required from here /usr/include/c++/10/bits/predefined_ops.h:96:22: error: no match for 'operator<' (operand types are 'Place' and 'Place') 96 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/stl_iterator.h:1096:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)' 1096 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1096:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/predefined_ops.h:96:22: note: 'Place' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 96 | { return __val < *__it; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/stl_iterator.h:1104:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)' 1104 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1104:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/predefined_ops.h:96:22: note: 'Place' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 96 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Value = Place]': /usr/include/c++/10/bits/stl_heap.h:139:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Distance = long int; _Tp = Place; _Compare = __gnu_cxx::__ops::_Iter_less_val]' /usr/include/c++/10/bits/stl_heap.h:246:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Distance = long int; _Tp = Place; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_heap.h:355:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1666:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1937:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1953:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:1974:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' /usr/include/c++/10/bits/stl_algo.h:4859:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<Place*, std::vector<Place> >]' bridge.cpp:53:42: required from here /usr/include/c++/10/bits/predefined_ops.h:67:22: error: no match for 'operator<' (operand types are 'Place' and 'Place') 67 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/stl_iterator.h:1096:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_IteratorL, _Container>&, const __gnu_cxx::__normal_iterator<_IteratorR, _Container>&)' 1096 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1096:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/predefined_ops.h:67:22: note: 'Place' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 67 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:67, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/stl_iterator.h:1104:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __gnu_cxx::__normal_iterator<_Iterator, _Container>&, const __gnu_cxx::__normal_iterator<_Iterator, _Container>&)' 1104 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/10/bits/stl_iterator.h:1104:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/bits/specfun.h:45, from /usr/include/c++/10/cmath:1927, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41, from bridge.cpp:2: /usr/include/c++/10/bits/predefined_ops.h:67:22: note: 'Place' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 67 | { return *__it < __val; } | ~~~~~~^~~~~~~