Submission #830552

# Submission time Handle Problem Language Result Execution time Memory
830552 2023-08-19T07:59:00 Z Minindu206 Sorting (IOI15_sorting) C++14
20 / 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 dif = 0;
	vector<int> pos(n, 0);
	for(int i=0;i<n;i++)
	{
		pos[s[i]] = i; 
	}
	int ind = 0;
	for(int i=0;i<n;i++)
	{
		
		// for(int j=0;j<n;j++)
		// 	cout << s[j] <<  " ";
		// cout << '\n';
		if(s[i] != i)
		{
			// cout << i << '\n';
			p[ind] = i;
			q[ind] = pos[i];
			int v = pos[i];
			pos[i] = i;
			pos[s[i]] = v;
			s[q[ind]] = s[i];
			s[i] = i;
			ind++;
		}
		// for(int j=0;j<n;j++)
		// 	cout << s[j] <<  " ";
		// cout << '\n';
	}
	return ind;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:6:6: warning: unused variable 'dif' [-Wunused-variable]
    6 |  int dif = 0;
      |      ^~~
sorting.cpp:4:39: warning: unused parameter 'm' [-Wunused-parameter]
    4 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[])
      |                                   ~~~~^
sorting.cpp:4:46: warning: unused parameter 'x' [-Wunused-parameter]
    4 | int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[])
      |                                          ~~~~^~~
sorting.cpp:4:55: warning: unused parameter 'y' [-Wunused-parameter]
    4 | 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 Correct 0 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 0 ms 212 KB Output is correct
# 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 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 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 Correct 0 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Incorrect 0 ms 212 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -