Submission #1053701

# Submission time Handle Problem Language Result Execution time Memory
1053701 2024-08-11T15:57:28 Z Osplei Sorting (IOI15_sorting) C++17
Compilation error
0 ms 0 KB
#include "sorting.h"
#include <bits/stdc++.h>

typedef long long ll;
typedef pair <ll, ll> LL;
ll mod = 1e9 + 7;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
  P[0] = 0;
	Q[0] = 0;

  vector <int> values;
  int ans = 0;

  for (ll i = 0; i < N; i++) values.pb(S[i]);

  sort(values.begin(), values.end());

  for (ll i = 0; i < N; i++) if (values[i] != S[i]) ans++;

  if (ans == 0) return 0;
  return (ans + 1) / 2;
}

Compilation message

sorting.cpp:5:9: error: 'pair' does not name a type
    5 | typedef pair <ll, ll> LL;
      |         ^~~~
sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:12:3: error: 'vector' was not declared in this scope
   12 |   vector <int> values;
      |   ^~~~~~
sorting.cpp:12:3: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sorting.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sorting.cpp:2:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
sorting.cpp:12:11: error: expected primary-expression before 'int'
   12 |   vector <int> values;
      |           ^~~
sorting.cpp:15:30: error: 'values' was not declared in this scope
   15 |   for (ll i = 0; i < N; i++) values.pb(S[i]);
      |                              ^~~~~~
sorting.cpp:17:8: error: 'values' was not declared in this scope
   17 |   sort(values.begin(), values.end());
      |        ^~~~~~
sorting.cpp:17:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   17 |   sort(values.begin(), values.end());
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from sorting.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
sorting.cpp:8:39: warning: unused parameter 'M' [-Wunused-parameter]
    8 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:8:46: warning: unused parameter 'X' [-Wunused-parameter]
    8 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:8:55: warning: unused parameter 'Y' [-Wunused-parameter]
    8 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~