답안 #1087013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087013 2024-09-12T03:49:12 Z the_coding_pooh 정렬하기 (IOI15_sorting) C++14
16 / 100
8 ms 604 KB
#include "sorting.h"
#include <bits/stdc++.h>
#define uwu return 0;

using namespace std;

const int SIZE = 2e5 + 5;

int s[SIZE], tar[SIZE], x[SIZE], y[SIZE], p[SIZE], q[SIZE], pos_of_val[SIZE];


void build(int M){
	for(int i = M - 1; i >= 0; i--){
		swap(tar[x[i]], tar[y[i]]);
	}
	return;
}

void get_sequence(int N, int M){
	for(int i = 0; i < M; i++){
		swap(s[x[i]], s[y[i]]);
		swap(tar[x[i]], tar[y[i]]);
		for(int j = 0; j < N; j++){
			if(s[j] != tar[j]){
				for(int k = j + 1; k < N; k++){
					if(s[k] == tar[j]){
						swap(s[j], s[k]);
						p[i] = j;
						q[i] = k;
					}
				}
				break;
			}
		}
	}
	return;
}

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	for(int i = 0; i < N; i++){
		tar[i] = i;
		s[i] = S[i];
	}
	for(int i = 0; i < M; i++){
		x[i] = X[i];
		y[i] = Y[i];
	}
	build(M);
	get_sequence(N, M);
	for(int i = 0; i < M; i++){
		P[i] = p[i];
		Q[i] = q[i];
	}
	return M;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -