답안 #89979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89979 2018-12-19T12:47:12 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:77: error: no match for 'operator-' (operand types are 'std::pair<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:79: note:   'std::pair<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:79: note:   'std::pair<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::pair<std::pair<int, int>, int>' to 'const std::_Bit_iterator_base&'
new_home.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &k, &q);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
new_home.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d", &x, &t, &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
new_home.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &l, &y);
         ~~~~~^~~~~~~~~~~~~~~~~