답안 #794905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
794905 2023-07-27T02:50:25 Z Username4132 정렬하기 (IOI15_sorting) C++14
20 / 100
3 ms 3540 KB
#include "sorting.h"
#include<iostream>
#include<algorithm>
using namespace std;
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forsn(i, s, n) for(int i=s; i<(int)n; ++i)

const int MAXN = 610;
int n, cou, arr[MAXN][MAXN];

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	n=N;
	forn(i, n) arr[0][i]=S[i];
	forn(i, n-1){
		forn(j, n) arr[i+1][j]=arr[i][j];
		swap(arr[i+1][X[i]], arr[i+1][Y[i]]);
	}
	forn(i, n-1){
		int num = arr[n-1][i];
		forsn(j, i+1, n){
			int x = find(arr[j], arr[j]+n, num) - arr[j];
			int y = find(arr[j], arr[j]+n, i) - arr[j];
			swap(arr[j][x], arr[j][y]);
			if(j==i+1 && x!=y) P[cou]=x, Q[cou]=y, ++cou;
		}
	}
	return cou;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:21:40: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   21 |    int x = find(arr[j], arr[j]+n, num) - arr[j];
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
sorting.cpp:22:38: warning: conversion from 'long int' to 'int' may change value [-Wconversion]
   22 |    int y = find(arr[j], arr[j]+n, i) - arr[j];
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
sorting.cpp:11:39: warning: unused parameter 'M' [-Wunused-parameter]
   11 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 1 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 3540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 3540 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -