Submission #428003

# Submission time Handle Problem Language Result Execution time Memory
428003 2021-06-15T07:04:04 Z haxorman Sorting (IOI15_sorting) C++14
0 / 100
174 ms 356 KB
#include "sorting.h"
#include "bits/stdc++.h"
using namespace std;

const int mxN = 2e5 + 7;

int n, m, arr[mxN];

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

	for (int i = 0; i < n; ++i) {
		arr[i] = S[i];
	}
	sort(S, S + n);

	int R = 0, ind = 0;

	swap(arr[X[ind]], arr[Y[ind]]);
	for (int i = 0; i < 2; ++i) {
		for (int j = 0; j < n; ++j) {
			if (arr[j] == S[i] && j != 1) {
				swap(arr[j], arr[1]);
				P[ind] = j, Q[ind] = 1;
				++R;
				++ind;
				break;
			}
		}
		swap(arr[X[ind]], arr[Y[ind]]);
	}

	for (int iter = 1; iter <= 50; ++iter) {
		for (int i = 2; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (arr[j] == S[i] && i != j) {
					swap(arr[j], arr[i]);
					P[ind] = j, Q[ind] = i;
					++R;
					++ind;
					break;
				}
			}
		}
		swap(arr[X[ind]], arr[Y[ind]]);
	}

	if (arr[0] != 0) {
		P[ind] = 0, Q[ind] = 1;
		++R;
		++ind; 
	}

	return R;
}


# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Integer 1 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 204 KB Integer 1 violates the range [0, 0]
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 2 ms 204 KB Integer 1 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -