Submission #794906

# Submission time Handle Problem Language Result Execution time Memory
794906 2023-07-27T02:52:12 Z Username4132 Sorting (IOI15_sorting) C++14
0 / 100
3 ms 3412 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;
		}
	}
	P[cou]=Q[cou]=0;
	return cou+1;
}

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[]) {
      |                                   ~~~~^
# Verdict Execution time Memory Grader output
1 Correct 0 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 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 3412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 3412 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -