Submission #1012290

# Submission time Handle Problem Language Result Execution time Memory
1012290 2024-07-01T22:53:49 Z aykhn Sorting (IOI15_sorting) C++17
Compilation error
0 ms 0 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[]) 
{
	for (int R = 0; R <= M; R++)
	{
		int f = -1;
		for (int i = 0; i < N; i++)
		{
			if (S[i] != i)
			{
				f = i;
				break;
			}
		}
		if (f == -1) return R;
      	swap(X[R], Y[R]);
		int f = -1;
		for (int i = 0; i < N; i++)
		{
			if (S[i] != i)
			{
				f = i;
				break;
			}
		}
		X[R] = f, Y[R] = S[f];
		swap(S[f], S[S[f]]);
	}
	assert(0);
	return -1;
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:21:7: error: redeclaration of 'int f'
   21 |   int f = -1;
      |       ^
sorting.cpp:10:7: note: 'int f' previously declared here
   10 |   int f = -1;
      |       ^
sorting.cpp:6:64: warning: unused parameter 'P' [-Wunused-parameter]
    6 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                                            ~~~~^~~
sorting.cpp:6:73: warning: unused parameter 'Q' [-Wunused-parameter]
    6 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[])
      |                                                                     ~~~~^~~