Submission #484035

# Submission time Handle Problem Language Result Execution time Memory
484035 2021-11-01T23:44:01 Z Cross_Ratio Sorting (IOI15_sorting) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "sorting.h"
typedef pair<long long int, int> P;
vector<P> So;
vector<long long int> S;
vector<int> X, Y, P, Q;
int N;
int findSwapPairs(int N2, int S2[], int M, int X2[], int Y2[], int P1[], int P2[]) {
    N = N2;
    int i, j;
    for(i=0;i<N;i++) {
        So.push_back(P(S2[i],i));
        S.push_back(S2[i]);
        X.push_back(X2[i]);
        Y.push_back(Y2[i]);
    }
    for(i=0;i<N;i++) {
        So[i].first = N * So[i].first + i;
        S[i] = N * S[i] + i;
    }
    sort(So.begin(),So.end());
    int cnt = 0;
    for(i=0;i<N;i++) {
        if(S[i] == So[i].first) continue;
        P1[cnt] = i;
        P2[cnt] = So[i].second;
        swap(S[i],S[So[i].second]);
        cnt++;
    }
    return cnt;
}

Compilation message

sorting.cpp:4:9: error: 'pair' does not name a type
    4 | typedef pair<long long int, int> P;
      |         ^~~~
sorting.cpp:5:1: error: 'vector' does not name a type
    5 | vector<P> So;
      | ^~~~~~
sorting.cpp:6:1: error: 'vector' does not name a type
    6 | vector<long long int> S;
      | ^~~~~~
sorting.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> X, Y, P, Q;
      | ^~~~~~
sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:13:9: error: 'So' was not declared in this scope; did you mean 'S2'?
   13 |         So.push_back(P(S2[i],i));
      |         ^~
      |         S2
sorting.cpp:13:22: error: 'P' was not declared in this scope
   13 |         So.push_back(P(S2[i],i));
      |                      ^
sorting.cpp:14:9: error: 'S' was not declared in this scope
   14 |         S.push_back(S2[i]);
      |         ^
sorting.cpp:15:9: error: 'X' was not declared in this scope
   15 |         X.push_back(X2[i]);
      |         ^
sorting.cpp:16:9: error: 'Y' was not declared in this scope
   16 |         Y.push_back(Y2[i]);
      |         ^
sorting.cpp:19:9: error: 'So' was not declared in this scope; did you mean 'S2'?
   19 |         So[i].first = N * So[i].first + i;
      |         ^~
      |         S2
sorting.cpp:20:9: error: 'S' was not declared in this scope
   20 |         S[i] = N * S[i] + i;
      |         ^
sorting.cpp:22:10: error: 'So' was not declared in this scope; did you mean 'S2'?
   22 |     sort(So.begin(),So.end());
      |          ^~
      |          S2
sorting.cpp:22:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   22 |     sort(So.begin(),So.end());
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sorting.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:4880:5: note: 'std::sort' declared here
 4880 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
sorting.cpp:25:12: error: 'S' was not declared in this scope
   25 |         if(S[i] == So[i].first) continue;
      |            ^
sorting.cpp:28:14: error: 'S' was not declared in this scope
   28 |         swap(S[i],S[So[i].second]);
      |              ^
sorting.cpp:28:9: error: 'swap' was not declared in this scope
   28 |         swap(S[i],S[So[i].second]);
      |         ^~~~
sorting.cpp:28:9: note: suggested alternatives:
In file included from /usr/include/c++/10/regex:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:110,
                 from sorting.cpp:2:
/usr/include/c++/10/bits/regex.h:2141:5: note:   'std::__cxx11::swap'
 2141 |     swap(match_results<_Bi_iter, _Alloc>& __lhs,
      |     ^~~~
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from sorting.cpp:2:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/10/bits/nested_exception.h:40,
                 from /usr/include/c++/10/exception:148,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from sorting.cpp:2:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
sorting.cpp:11:12: warning: unused variable 'j' [-Wunused-variable]
   11 |     int i, j;
      |            ^
sorting.cpp:9:41: warning: unused parameter 'M' [-Wunused-parameter]
    9 | int findSwapPairs(int N2, int S2[], int M, int X2[], int Y2[], int P1[], int P2[]) {
      |                                     ~~~~^