# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
988830 | HienTD | Advertisement 2 (JOI23_ho_t2) | C++11 | 컴파일 에러 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
int ri() {
int n;
scanf("%d", &n);
return n;
}
int main() {
int N = ri();
std::vector<std::pair<int, int> > points(N);
for (int i = 0; i < N; i++) {
int X = ri();
int E = ri();
points[i] = {X - E, X + E}; // {a[i], b[i]}
}
// aåŒã˜ãªã‚‰bé™é †ã«ã™ã‚‹ã¨ã€aãŒåŒã˜ã‚„ã¤ã§è¤‡æ•°å›žbã®æœ€å¤§å€¤ã‚’æ›´æ–°ã—ã¦ã—ã¾ã£ãŸã‚Šã—ãªããªã‚‹
std::sort(points.begin(), points.end(), [] (auto &i, auto &j) {
if (i.first != j.first) return i.first < j.first;
return i.second > j.second;
});
int max = -1;
int cnt = 0;
for (auto i : points) if (max < i.second) max = i.second, cnt++;
printf("%d\n", cnt);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()': Main.cpp:22:46: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14' 22 | std::sort(points.begin(), points.end(), [] (auto &i, auto &j) { | ^~~~ Main.cpp:22:55: error: use of 'auto' in lambda parameter declaration only available with '-std=c++14' or '-std=gnu++14' 22 | std::sort(points.begin(), points.end(), [] (auto &i, auto &j) { | ^~~~ Main.cpp: In lambda function: Main.cpp:23:9: error: request for member 'first' in 'i', which is of non-class type 'int' 23 | if (i.first != j.first) return i.first < j.first; | ^~~~~ Main.cpp:23:20: error: request for member 'first' in 'j', which is of non-class type 'int' 23 | if (i.first != j.first) return i.first < j.first; | ^~~~~ Main.cpp:23:36: error: request for member 'first' in 'i', which is of non-class type 'int' 23 | if (i.first != j.first) return i.first < j.first; | ^~~~~ Main.cpp:23:46: error: request for member 'first' in 'j', which is of non-class type 'int' 23 | if (i.first != j.first) return i.first < j.first; | ^~~~~ Main.cpp:24:12: error: request for member 'second' in 'i', which is of non-class type 'int' 24 | return i.second > j.second; | ^~~~~~ Main.cpp:24:23: error: request for member 'second' in 'j', which is of non-class type 'int' 24 | return i.second > j.second; | ^~~~~~ In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/vector:60, from Main.cpp:2: /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = main()::<lambda(int&, int&)>]': /usr/include/c++/10/bits/stl_algo.h:1846:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /usr/include/c++/10/bits/stl_algo.h:1977:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = main()::<lambda(int&, int&)>]' Main.cpp:25:3: required from here /usr/include/c++/10/bits/predefined_ops.h:156:30: error: no match for call to '(main()::<lambda(int&, int&)>) (std::pair<int, int>&, std::pair<int, int>&)' 156 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ Main.cpp:22:42: note: candidate: 'main()::<lambda(int&, int&)>' 22 | std::sort(points.begin(), points.end(), [] (auto &i, auto &j) { | ^ Main.cpp:22:42: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'int&' In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/vector:60, from Main.cpp:2: /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<int, int>; _Iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = main()::<lambda(int&, int&)>]': /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<main()::<lambda(int&, int&)> >]' /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /usr/include/c++/10/bits/stl_algo.h:1977:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = main()::<lambda(int&, int&)>]' Main.cpp:25:3: required from here /usr/include/c++/10/bits/predefined_ops.h:238:23: error: no match for call to '(main()::<lambda(int&, int&)>) (std::pair<int, int>&, std::pair<int, int>&)' 238 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ Main.cpp:22:42: note: candidate: 'main()::<lambda(int&, int&)>' 22 | std::sort(points.begin(), points.end(), [] (auto &i, auto &j) { | ^ Main.cpp:22:42: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'int&' In file included from /usr/include/c++/10/bits/stl_algobase.h:71, from /usr/include/c++/10/vector:60, from Main.cpp:2: /usr/include/c++/10/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Value = std::pair<int, int>; _Compare = main()::<lambda(int&, int&)>]': /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Distance = long int; _Tp = std::pair<int, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<main()::<lambda(int&, int&)> >]' /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Distance = long int; _Tp = std::pair<int, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /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<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /usr/include/c++/10/bits/stl_algo.h:1974:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(int&, int&)> >]' /usr/include/c++/10/bits/stl_algo.h:4892:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<int, int>*, std::vector<std::pair<int, int> > >; _Compare = main()::<lambda(int&, int&)>]' Main.cpp:25:3: required from here /usr/include/c++/10/bits/predefined_ops.h:194:23: error: no match for call to '(main()::<lambda(int&, int&)>) (std::pair<int, int>&, std::pair<int, int>&)' 194 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~ Main.cpp:22:42: note: candidate: 'main()::<lambda(int&, int&)>' 22 | std::sort(points.begin(), points.end(), [] (auto &i, auto &j) { | ^ Main.cpp:22:42: note: no known conversion for argument 1 from 'std::pair<int, int>' to 'int&' Main.cpp: In function 'int ri()': Main.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result] 8 | scanf("%d", &n); | ~~~~~^~~~~~~~~~