记录详情

Compile Error

foo.cc: In function ‘int main()’:
foo.cc:15:23: error: no match for ‘operator-’ (operand types are ‘std::unordered_set<int>’ and ‘int’)
   15 |         if (s.count(s - x))
      |                     ~ ^ ~
      |                     |   |
      |                     |   int
      |                     std::unordered_set<int>
In file included from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/string:48,
                 from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/locale_classes.h:40,
                 from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/ios_base.h:41,
                 from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/ios:44,
                 from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/ostream:40,
                 from iostream:41:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_iterator.h:618:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)’
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
foo.cc:15:25: note:   ‘std::unordered_set<int>’ is not derived from ‘const std::reverse_iterator<_Iterator>’
   15 |         if (s.count(s - x))
      |                         ^
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_iterator.h:1790:5: note: candidate: ‘template<class _IteratorL, class _IteratorR> decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)’
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
foo.cc:15:25: note:   ‘std::unordered_set<int>’ is not derived from ‘const std::move_iterator<_IteratorL>’
   15 |         if (s.count(s - x))
      |                         ^

信息

递交者
类型
递交
题目
6-1 和为定值的数对
比赛
2025年春 南师大《程序设计与竞赛》作业赛第六场
语言
C++
递交时间
2025-05-10 22:00:22
评测时间
2025-05-10 22:00:22
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes