답안 #764731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764731 2023-06-24T02:37:23 Z SanguineChameleon 정렬하기 (IOI15_sorting) C++17
36 / 100
48 ms 852 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	int len = 0;
	for (int i = 0; ; i++) {
		bool ok = true;
		for (int j = 0; j < N; j++) {
			if (S[j] != j) {
				ok = false;
				break;
			}
		}
		if (ok) {
			return len;
		}
		assert(i < M);
		swap(S[X[i]], S[Y[i]]);
		vector<int> wrong;
		for (int j = 0; j < N; j++) {
			if (S[j] != j) {
				wrong.push_back(j);
			}
		}
		if (wrong.empty()) {
			P[len] = 0;
			Q[len] = 0;
		}
		else {
			shuffle(wrong.begin(), wrong.end(), gen);
			P[len] = wrong[0];
			for (int j = 0; j < N; j++) {
				if (S[j] == wrong[0]) {
					Q[len] = j;
					break;
				}
			}
		}
		swap(S[P[len]], S[Q[len]]);
		len++;
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 236 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 236 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 236 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Runtime error 48 ms 852 KB Execution killed with signal 6
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -