답안 #71653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
71653 2018-08-25T09:52:01 Z SmsS 정렬하기 (IOI15_sorting) C++14
0 / 100
4 ms 640 KB
#include<bits/stdc++.h>
using namespace std;
#define for2(a,b,c) for(int a=b;a<c;a++)
#include "sorting.h"

int findSwapPairs(int n, int s[], int M, int X[], int Y[], int P[], int Q[]) {
	vector<int> S(n);
	for2(i,0,n) S[i] = s[i];
	int r = 0;
	for(int cur = n-1; cur >= 0; cur--){
		if(is_sorted(S.begin(),S.end())){
			break;
		}
		swap(S[X[r]],S[Y[r]]);
		for2(i,0,n) if(S[i] == cur){
			P[r] = min(i,cur);
			Q[r] = max(i,cur);
			swap(S[i],S[cur]);
			r++;
			break;
		}
	}
	if(S[0] != 0){
		swap(S[X[r]],S[Y[r]]);
		P[r] =Q[r] = 0;
		r++;
	}
	if(r > M){
		assert(1);
		assert(0);
	}
	if(!is_sorted(S.begin(),S.end())) { assert(0); assert(1);}
	return r;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB Output is correct
2 Incorrect 3 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -