Submission #426865

# Submission time Handle Problem Language Result Execution time Memory
426865 2021-06-14T10:34:55 Z ollel Sorting (IOI15_sorting) C++17
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define lso(x) x&(-x)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

#include <bits/stdc++.h>
#include <iostream>
using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define lso(x) x&(-x)

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;


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

  rep(i, 0, n) if (S[i] == 0) {
    swap(S[0], S[1]);
    swap(S[i], S[0]);
    P[r] = 0;
    Q[r] = i;
    r++;
  }

  rep(i, 0, n) if (S[i] == 1) {
    swap(S[0], S[1]);
    swap(S[i], S[0]);
    P[r] = 0;
    Q[r] = i;
    r++;
  }

  rep(i,2,n) {
    while (S[i] != i) {
      P[r] = i; Q[r] = S[i];
      swap(S[0], S[1]);
      swap(S[i], S[S[i]]);
      r++;
    }
  }

  if (S[0] != 0) {
    swap(S[0], S[1]);
    P[r] = Q[r] = 0;
    r++;
  }

  return r;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:26:39: warning: unused parameter 'M' [-Wunused-parameter]
   26 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:26:46: warning: unused parameter 'X' [-Wunused-parameter]
   26 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
sorting.cpp:26:55: warning: unused parameter 'Y' [-Wunused-parameter]
   26 | int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                                   ~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -