Submission #621368

# Submission time Handle Problem Language Result Execution time Memory
621368 2022-08-03T18:05:51 Z A_D Sorting (IOI15_sorting) C++14
0 / 100
29 ms 888 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+100;
int a[N];
int n;
int num=0;


int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    num=0;
    n=N;
    for(int i=0;i<N;i++){
        a[i]=S[i];
    }
    if(n==1)return num;

    for(int i=0;i<n;i++){
        int f=1;
        for(int j=i;j<n;j++){
            if(a[j]==i){
                P[num]=j;
                Q[num]=j;
                num++;
            }
            f=1;
            for(int h=0;h<n;h++){
                if(a[h]!=h)f=0;
            }
            if(f)break;

            P[num]=0;
            Q[num]=0;
            num++;



        }
        if(f)break;
    }
    return num;
}













Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:10:23: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   10 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                   ~~~~^
sorting.cpp:4:11: note: shadowed declaration is here
    4 | const int N=2e5+100;
      |           ^
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 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 888 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 888 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -