Submission #1053702

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

using namespace std;

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: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:17:37: error: 'class std::vector<int>' has no member named 'pb'
   17 |   for (ll i = 0; i < N; i++) values.pb(S[i]);
      |                                     ^~
sorting.cpp:10:39: warning: unused parameter 'M' [-Wunused-parameter]
   10 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:10:46: warning: unused parameter 'X' [-Wunused-parameter]
   10 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:10:55: warning: unused parameter 'Y' [-Wunused-parameter]
   10 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~