답안 #832578

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832578 2023-08-21T11:57:30 Z aymanrs 정렬하기 (IOI15_sorting) C++14
54 / 100
188 ms 664 KB
#include <bits/stdc++.h>
#include "sorting.h"
using namespace std;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	int R = 0;
	for(int i = 0;i < M;i++){
	    if(is_sorted(S, S+N)) return R;
		R++;
		swap(S[X[i]], S[Y[i]]);
		int opt[N];
		for(int j = 0;j<N;j++) opt[j]=j;
		for(int j = M-1;j > i;j--) swap(opt[X[j]], opt[Y[j]]);
		bool f = false;
		for(int j = 0;j < N;j++){
			if(S[j] != opt[j]){
				f = true;
				for(int k = j+1;k < N;k++) {
					if(S[k] == opt[j]) {
						P[R-1] = j;
						Q[R-1] = k;
						swap(S[j], S[k]);
						break;
					}
				}
				break;
			}
		}
		if(!f) P[R-1] = Q[R-1] = 0;
	}
	assert(is_sorted(S, S+N));
	return R;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 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 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 304 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 0 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 300 KB Output is correct
21 Correct 98 ms 608 KB Output is correct
22 Correct 103 ms 648 KB Output is correct
23 Correct 188 ms 608 KB Output is correct
24 Correct 101 ms 548 KB Output is correct
25 Correct 102 ms 664 KB Output is correct
26 Correct 95 ms 572 KB Output is correct
27 Correct 102 ms 660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 416 KB Output isn't correct
2 Halted 0 ms 0 KB -