Submission #793645

# Submission time Handle Problem Language Result Execution time Memory
793645 2023-07-26T05:04:22 Z Jarif_Rahman Sorting (IOI15_sorting) C++17
20 / 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 = 0; i < n; i++){
        if(i == S[i]) continue;
        P[ans] = i, Q[ans] = pos[i];
        ans++;
        swap(pos[S[i]], pos[i]);
        swap(S[i], S[pos[S[i]]]);
    }

    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 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Incorrect 1 ms 212 KB Output isn't correct
15 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 -