Submission #133615

# Submission time Handle Problem Language Result Execution time Memory
133615 2019-07-21T06:39:38 Z Mahdi_Jfri Sorting (IOI15_sorting) C++14
Compilation error
0 ms 0 KB
#include "sorting.h"
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back

const int maxn = 2e3 + 20;

int pos[maxn][maxn];

int findSwapPairs(int n, int a[], int m, int x[], int y[], int p[], int q[])
{
	swap(a[x[0]] , a[y[0]]);

	for(int i = 0; i < n; i++)
		pos[m - 1][i] = i;
	for(int i = m - 2; i >= 0; i--)
	{
		memcpy(pos[i] , pos[i + 1] , sizeof pos[i + 1]);
		swap(pos[i][x[i + 1]] , pos[i][y[i + 1]]);
	}

	for(int i = 0; i < m; i++)
	{
		for(int j = 0; j < n; j++)
			if(pos[i][j] != a[j])
			{
				f = 1;
				int ind = -1;
				for(int k = 0; k < n; k++)
					if(pos[i][k] == a[j])
						ind = k;

				while(ind < 0);
				p[i] = j , q[i] = ind;
				swap(a[j] , a[ind]);
				break;
			}

		swap(a[x[i + 1]] , a[y[i + 1]]);
	}

	return m;
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:30:5: error: 'f' was not declared in this scope
     f = 1;
     ^