답안 #428092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
428092 2021-06-15T08:00:48 Z haxorman 정렬하기 (IOI15_sorting) C++14
8 / 100
1 ms 332 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];
	}

	int R = 0, ind = 0;
	bool ok = false;
	for (int iter = 1; iter <= m / n && !ok; ++iter) {
		swap(arr[X[ind]], arr[Y[ind]]);

		ok = true;
		for (int i = 0; i < n && ok; ++i) {
			if (ind + 1 < m && (i == X[ind + 1] || i == Y[ind + 1]))
				continue;

			for (int j = 0; j < n && ok; ++j) {
				if (arr[j] == i && i != j) {
					swap(arr[j], arr[i]);
					P[ind] = j, Q[ind] = i;
					++R;
					++ind;
					ok = false;
				}
			}
		}

		for (int i = 0; i < n; ++i) {
			if (arr[i] != i) {
				ok = false;
			}
		}
	}

	return R;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Incorrect 1 ms 332 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Incorrect 1 ms 332 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -