Submission #65651

# Submission time Handle Problem Language Result Execution time Memory
65651 2018-08-08T10:58:22 Z mirbek01 Sorting (IOI15_sorting) C++17
0 / 100
5 ms 640 KB
#include "sorting.h"

# include <bits/stdc++.h>

using namespace std;

int pos[1000];

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {

      for(int i = 0; i < N; i ++)
            pos[S[i]] = i;

      int sz = 0;

      for(int i = N - 1; i > 0; i --){
            bool fl = 1;
            for(int j = 0; j < N; j ++){
                  if(j != S[j]) fl = 0;
            }
            if(fl) break;
            swap(S[X[sz]], S[Y[sz]]);
            pos[S[X[sz]]] = X[sz];
            pos[S[Y[sz]]] = Y[sz];
            P[sz] = pos[i], Q[sz] = i;
            swap(S[i], S[pos[i]]);
            pos[ S[pos[i]] ] = pos[i];
            sz ++;
      }

	return sz;
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:9:39: warning: unused parameter 'M' [-Wunused-parameter]
 int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
                                       ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 3 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Incorrect 3 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -