# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89980 | 2018-12-19T12:47:45 Z | tjdgus4384 | 새 집 (APIO18_new_home) | C++14 | 컴파일 오류 |
0 ms | 0 KB |
#include<cstdio> #include<vector> #include<algorithm> #include<set> #include<map> using namespace std; multimap<pair<int, int>, int> m; multiset<int> typeyear[300001]; multiset<int> yearnum; int main(){ int n, q, k, x, t, a, b, l, y; scanf("%d %d %d", &n, &k, &q); for(int i = 0;i < n;i++){ scanf("%d %d %d %d", &x, &t, &a, &b); for(int j = a;j <= b;j++){ if(typeyear[t].count(j) == 0){ yearnum.insert(j); typeyear[t].insert(j); } m.insert({{j, t}, x}); } } for(int i = 0;i < q;i++){ scanf("%d %d", &l, &y); if(yearnum.count(y) < k) printf("-1\n"); else{ int ans = 0; for(int j = 1;j <= k;j++){ auto a = m.lower_bound({y, j}); auto b = m.upper_bound({y, j}); auto iter = lower_bound(a, b, make_pair(make_pair(y, j), l)) - a; if(iter == b) iter--; ans = max(abs(iter->second - l), ans); } printf("%d\n", ans); } } return 0; }
Compilation message
new_home.cpp: In function 'int main()': new_home.cpp:27:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(yearnum.count(y) < k) printf("-1\n"); ~~~~~~~~~~~~~~~~~^~~ new_home.cpp:33:78: error: no match for 'operator-' (operand types are 'std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >' and 'std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >') auto iter = lower_bound(a, b, make_pair(make_pair(y, j), l)) - a; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:389:5: note: candidate: template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator-(const reverse_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:389:5: note: template argument deduction/substitution failed: new_home.cpp:33:80: note: 'std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >' is not derived from 'const std::reverse_iterator<_Iterator>' auto iter = lower_bound(a, b, make_pair(make_pair(y, j), l)) - a; ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:1191:5: note: candidate: template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&) operator-(const move_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1191:5: note: template argument deduction/substitution failed: new_home.cpp:33:80: note: 'std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >' is not derived from 'const std::move_iterator<_IteratorL>' auto iter = lower_bound(a, b, make_pair(make_pair(y, j), l)) - a; ^ In file included from /usr/include/c++/7/vector:65:0, from new_home.cpp:2: /usr/include/c++/7/bits/stl_bvector.h:208:3: note: candidate: std::ptrdiff_t std::operator-(const std::_Bit_iterator_base&, const std::_Bit_iterator_base&) operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_bvector.h:208:3: note: no known conversion for argument 1 from 'std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >' to 'const std::_Bit_iterator_base&' In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >; _Value = const std::pair<std::pair<int, int>, int>]': /usr/include/c++/7/bits/stl_algobase.h:959:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >; _Tp = std::pair<std::pair<int, int>, int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' /usr/include/c++/7/bits/stl_algobase.h:993:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = std::_Rb_tree_iterator<std::pair<const std::pair<int, int>, int> >; _Tp = std::pair<std::pair<int, int>, int>]' new_home.cpp:33:76: required from here /usr/include/c++/7/bits/predefined_ops.h:65:22: error: no match for 'operator<' (operand types are 'std::pair<const std::pair<int, int>, int>' and 'const std::pair<std::pair<int, int>, int>') { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:888: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>&) operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:888:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:895: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>&) operator<(const __normal_iterator<_Iterator, _Container>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:895:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/map:62:0, from new_home.cpp:5: /usr/include/c++/7/bits/stl_multimap.h:1078:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&) operator<(const multimap<_Key, _Tp, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_multimap.h:1078:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::multimap<_Key, _Tp, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/map:61:0, from new_home.cpp:5: /usr/include/c++/7/bits/stl_map.h:1412:5: note: candidate: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator<(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&) operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_map.h:1412:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::map<_Key, _Tp, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_map.h:63:0, from /usr/include/c++/7/map:61, from new_home.cpp:5: /usr/include/c++/7/tuple:1410:5: note: candidate: template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const std::tuple<_Tps ...>&, const std::tuple<_Args2 ...>&) operator<(const tuple<_TElements...>& __t, ^~~~~~~~ /usr/include/c++/7/tuple:1410:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::tuple<_Tps ...>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/tuple:39:0, from /usr/include/c++/7/bits/stl_map.h:63, from /usr/include/c++/7/map:61, from new_home.cpp:5: /usr/include/c++/7/array:262:5: note: candidate: template<class _Tp, long unsigned int _Nm> bool std::operator<(const std::array<_Tp, _Nm>&, const std::array<_Tp, _Nm>&) operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b) ^~~~~~~~ /usr/include/c++/7/array:262:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::array<_Tp, _Nm>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/stdexcept:39, from /usr/include/c++/7/array:39, from /usr/include/c++/7/tuple:39, from /usr/include/c++/7/bits/stl_map.h:63, from /usr/include/c++/7/map:61, from new_home.cpp:5: /usr/include/c++/7/bits/basic_string.h:6107:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator<(const _CharT* __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6107:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: mismatched types 'const _CharT*' and 'std::pair<const std::pair<int, int>, int>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/stdexcept:39, from /usr/include/c++/7/array:39, from /usr/include/c++/7/tuple:39, from /usr/include/c++/7/bits/stl_map.h:63, from /usr/include/c++/7/map:61, from new_home.cpp:5: /usr/include/c++/7/bits/basic_string.h:6095:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6095:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/string:52:0, from /usr/include/c++/7/stdexcept:39, from /usr/include/c++/7/array:39, from /usr/include/c++/7/tuple:39, from /usr/include/c++/7/bits/stl_map.h:63, from /usr/include/c++/7/map:61, from new_home.cpp:5: /usr/include/c++/7/bits/basic_string.h:6082:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^~~~~~~~ /usr/include/c++/7/bits/basic_string.h:6082:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/set:62:0, from new_home.cpp:4: /usr/include/c++/7/bits/stl_multiset.h:913:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator<(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&) operator<(const multiset<_Key, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_multiset.h:913:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::multiset<_Key, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/set:61:0, from new_home.cpp:4: /usr/include/c++/7/bits/stl_set.h:930:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator<(const std::set<_Key, _Compare, _Alloc>&, const std::set<_Key, _Compare, _Alloc>&) operator<(const set<_Key, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_set.h:930:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::set<_Key, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/set:60:0, from new_home.cpp:4: /usr/include/c++/7/bits/stl_tree.h:1543:5: note: candidate: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator<(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&) operator<(const _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_tree.h:1543:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/vector:64:0, from new_home.cpp:2: /usr/include/c++/7/bits/stl_vector.h:1613:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator<(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) ^~~~~~~~ /usr/include/c++/7/bits/stl_vector.h:1613:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::vector<_Tp, _Alloc>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:1148:5: note: candidate: template<class _Iterator> bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorL>&) operator<(const move_iterator<_Iterator>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1148:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::move_iterator<_IteratorL>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:1142:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::operator<(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&) operator<(const move_iterator<_IteratorL>& __x, ^~~~~~~~ /usr/include/c++/7/bits/stl_iterator.h:1142:5: note: template argument deduction/substitution failed: In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/predefined_ops.h:65:22: note: 'std::pair<const std::pair<int, int>, int>' is not derived from 'const std::move_iterator<_IteratorL>' { return *__it < __val; } ~~~~~~^~~~~~~ In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0, from /usr/include/c++/7/vector:60, from new_home.cpp:2: /usr/include/c++/7/bits/stl_iterator.h:343:5: note: candidate: template<class _IteratorL, class _IteratorR> bool std::ope