답안 #795507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
795507 2023-07-27T10:37:05 Z Cauchico 정렬하기 (IOI15_sorting) C++14
0 / 100
1 ms 340 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    int n = N, m = M;
	int swaps = m;
	for (int i=0;i<m;i++) {
		P[i] = Q[i] = 0;
	}
	for (int i=0;i<n;i++) {
		bool flag = false;
		for (int i=1;i<n;i++) {
			if (S[i] < S[i-1]) flag = true;
		}
		if (flag) {
			swaps = i;
			break;
		}
		for (int j=0;j<n;j++) {
			if (S[j] == i) {
				swap(S[j], S[i]);
				P[i] = i;
				Q[i] = j;
			}
		}
	}
	swaps = n;
	if (Y[0] == 1 and m&1) {
		Q[m-1] = 1;
		swaps++;
	}
	return swaps;

}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:13:12: warning: declaration of 'i' shadows a previous local [-Wshadow]
   13 |   for (int i=1;i<n;i++) {
      |            ^
sorting.cpp:11:11: note: shadowed declaration is here
   11 |  for (int i=0;i<n;i++) {
      |           ^
sorting.cpp:5:46: warning: unused parameter 'X' [-Wunused-parameter]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -