Submission #1195171

#TimeUsernameProblemLanguageResultExecution timeMemory
1195171nikulid정렬하기 (IOI15_sorting)C++20
Compilation error
0 ms0 KiB
#include "sorting.h" #include <vector> using namespace std; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { //bool already_sorted; //bool CHECKING=false, DEBUG=false; // we are given S[], M, X[], Y[] // we are to give P[], Q[] vector<int> ns(N); for(int i=0; i<N; i++){ ns[i] = S[i]; } /*if(DEBUG) { for(auto x:ns){ cout<<x<<" "; }cout<<"\n\n"; }*/ for(int i=0; i<N; i++){ for(int j=0; j<N; j++){ if(ns[j] == i){ next = j; break; } } P[i] = i; Q[i] = next; swap(ns[i], ns[next]); // we have "swapped" positions `i` and `trans[i]`. whatever that means. } /*for(auto x:ns){ cout<<x<<" "; }cout<<"\n\n";*/ return N; }

Compilation message (stderr)

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:25:32: error: overloaded function with no contextual type information
   25 |                         next = j;
      |                                ^
sorting.cpp:30:16: error: cannot resolve overloaded function 'next' based on conversion to type 'int'
   30 |         Q[i] = next;
      |                ^~~~
sorting.cpp:31:23: error: no match for 'operator[]' (operand types are 'std::vector<int>' and '<unresolved overloaded function type>')
   31 |         swap(ns[i], ns[next]);
      |                       ^
In file included from /usr/include/c++/11/vector:67,
                 from sorting.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1043:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1043 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]'
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1061:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1061 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~