Compile Error

foo.cc: In function ‘int main()’:
foo.cc:9:23: error: invalid types ‘int[int]’ for array subscript
    9 |                 cin>>x[i];
      |                       ^
foo.cc:13:24: error: invalid types ‘int[int]’ for array subscript
   13 |                 cout<<x[i]<<" ";
      |                        ^
In file included from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/algorithm:61,
                 from stdc++.h:51:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h: In instantiation of ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1817:25:   required from ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1908:31:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:4772:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = int]’
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.cc:11:6:   required from here
   11 |         sort(x,x+n);
      |         ~~~~^~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1780:17: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
 1780 |                 __val = _GLIBCXX_MOVE(*__i);
      |                 ^~~~~
In file included from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_pair.h:61,
                 from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algobase.h:64,
                 from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/algorithm:60:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1780:25: error: invalid type argument of unary ‘*’ (have ‘int’)
 1780 |                 __val = _GLIBCXX_MOVE(*__i);
      |                         ^~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1782:15: error: invalid type argument of unary ‘*’ (have ‘int’)
 1782 |               *__first = _GLIBCXX_MOVE(__val);
      |               ^~~~~~~~
In file included from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algobase.h:71:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/predefined_ops.h: In instantiation of ‘bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = int; _Iterator2 = int]’:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1777:14:   required from ‘void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1777 |           if (__comp(__i, __first))
      |               ~~~~~~^~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1817:25:   required from ‘void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1908:31:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:4772:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = int]’
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.cc:11:6:   required from here
   11 |         sort(x,x+n);
      |         ~~~~^~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/predefined_ops.h:45:16: error: invalid type argument of unary ‘*’ (have ‘int’)
   45 |       { return *__it1 < *__it2; }
      |                ^~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/predefined_ops.h:45:25: error: invalid type argument of unary ‘*’ (have ‘int’)
   45 |       { return *__it1 < *__it2; }
      |                         ^~~~~~
In file included from /nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:61:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h: In instantiation of ‘void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1593:23:   required from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1593 |       std::__make_heap(__first, __middle, __comp);
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1868:25:   required from ‘void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1868 |       std::__heap_select(__first, __middle, __last, __comp);
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1884:27:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1884 |               std::__partial_sort(__first, __last, __last, __comp);
      |               ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1905:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1905 |           std::__introsort_loop(__first, __last,
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1907 |                                 __comp);
      |                                 ~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:4772:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = int]’
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.cc:11:6:   required from here
   11 |         sort(x,x+n);
      |         ~~~~^~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h:344:11: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
  344 |           _ValueType;
      |           ^~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h:346:11: error: no type named ‘difference_type’ in ‘struct std::iterator_traits<int>’
  346 |           _DistanceType;
      |           ^~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h: In instantiation of ‘void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1596:19:   required from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1596 |           std::__pop_heap(__first, __middle, __i, __comp);
      |           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1868:25:   required from ‘void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1868 |       std::__heap_select(__first, __middle, __last, __comp);
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1884:27:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1884 |               std::__partial_sort(__first, __last, __last, __comp);
      |               ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1905:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1905 |           std::__introsort_loop(__first, __last,
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1907 |                                 __comp);
      |                                 ~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:4772:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = int]’
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.cc:11:6:   required from here
   11 |         sort(x,x+n);
      |         ~~~~^~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h:258:9: error: no type named ‘value_type’ in ‘struct std::iterator_traits<int>’
  258 |         _ValueType;
      |         ^~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h:260:9: error: no type named ‘difference_type’ in ‘struct std::iterator_traits<int>’
  260 |         _DistanceType;
      |         ^~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h:262:28: error: invalid type argument of unary ‘*’ (have ‘int’)
  262 |       _ValueType __value = _GLIBCXX_MOVE(*__result);
      |                            ^~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h:263:7: error: invalid type argument of unary ‘*’ (have ‘int’)
  263 |       *__result = _GLIBCXX_MOVE(*__first);
      |       ^~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_heap.h:263:19: error: invalid type argument of unary ‘*’ (have ‘int’)
  263 |       *__result = _GLIBCXX_MOVE(*__first);
      |                   ^~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algobase.h: In instantiation of ‘void std::iter_swap(_ForwardIterator1, _ForwardIterator2) [with _ForwardIterator1 = int; _ForwardIterator2 = int]’:
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:91:20:   required from ‘void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
   91 |             std::iter_swap(__result, __b);
      |             ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1855:34:   required from ‘_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1855 |       std::__move_median_to_first(__first, __first + 1, __mid, __last - 1,
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1856 |                                   __comp);
      |                                   ~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1889:38:   required from ‘void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1889 |             std::__unguarded_partition_pivot(__first, __last, __comp);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:1905:25:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
 1905 |           std::__introsort_loop(__first, __last,
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
 1906 |                                 std::__lg(__last - __first) * 2,
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1907 |                                 __comp);
      |                                 ~~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algo.h:4772:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = int]’
 4772 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo.cc:11:6:   required from here
   11 |         sort(x,x+n);
      |         ~~~~^~~~~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algobase.h:185:12: error: invalid type argument of unary ‘*’ (have ‘int’)
  185 |       swap(*__a, *__b);
      |            ^~~~
/nix/gcc-14.2.1.20250322/include/c++/14.2.1.20250322/bits/stl_algobase.h:185:18: error: invalid type argument of unary ‘*’ (have ‘int’)
  185 |       swap(*__a, *__b);
      |                  ^~~~

信息

递交者
类型
递交
题目
P2501 合唱队形
语言
C++
递交时间
2025-05-10 14:18:54
评测时间
2025-05-10 14:18:54
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes