Submission #803000

# Submission time Handle Problem Language Result Execution time Memory
803000 2023-08-02T17:40:54 Z BT21tata Sorting (IOI15_sorting) C++17
16 / 100
6 ms 452 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;

int cur[200005];

int findSwapPairs(int n, int s[], int m, int x[], int y[], int P[], int Q[])
{
	m=n;
	int r=0;
	for(int i=0; i<m; i++)
	{
		swap(s[x[i]], s[y[i]]);
		for(int j=0; j<n; j++)
			cur[j]=s[j];
		for(int j=i+1; j<m; j++)
			swap(cur[x[j]], cur[y[j]]);
		
		int pos1, pos2;
		for(int j=0; j<n; j++)
		{
			if(s[j]==cur[i]) pos1=j;
			if(s[j]==i) pos2=j;
		}
		P[r]=pos1;
		Q[r]=pos2;
		swap(s[P[r]], s[Q[r]]);
		r++;
	}
	return m;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:27:22: warning: 'pos2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |   swap(s[P[r]], s[Q[r]]);
      |                   ~~~^
sorting.cpp:25:7: warning: 'pos1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |   P[r]=pos1;
      |   ~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 312 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 312 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 232 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Incorrect 1 ms 312 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -