Submission #793658

# Submission time Handle Problem Language Result Execution time Memory
793658 2023-07-26T05:10:40 Z Jarif_Rahman Sorting (IOI15_sorting) C++17
16 / 100
1 ms 340 KB
#include "sorting.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[]){
    vector<int> pos(n);
    for(int i = 0; i < n; i++) pos[S[i]] = i;

    int ans = 0;
    for(int i = 2; i < n; i++){
        if(i == S[i]) continue;
        swap(S[0], S[1]);
        swap(pos[S[0]], pos[S[1]]);
        P[ans] = i, Q[ans] = pos[i];
        ans++;
        swap(pos[S[i]], pos[i]);
        swap(S[i], S[pos[S[i]]]);
    }

    if(S[0] != 0) P[ans] = 0, Q[ans] = 0, ans++;

    return ans;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
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[]){
      |                                                   ~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -