Submission #422706

# Submission time Handle Problem Language Result Execution time Memory
422706 2021-06-10T10:53:51 Z vanic Sorting (IOI15_sorting) C++14
0 / 100
1 ms 332 KB
#include "sorting.h"
#include <algorithm>

using namespace std;

const int maxn=2e5+5;

int pos[maxn];

int findSwapPairs(int n, int l[], int m, int x[], int y[], int p[], int q[]){
	for(int i=0; i<n; i++){
		pos[l[i]]=i;
	}
	int br=2;
	int dr;
	for(int i=0; i<n-2; i++){
		swap(l[x[i]], l[y[i]]);
		swap(pos[l[x[i]]], pos[l[y[i]]]);
		p[i]=pos[br];
		q[i]=br;
		dr=l[br];
		swap(l[pos[dr]], l[pos[br]]);
		swap(pos[br], pos[dr]);
		br++;
	}
	int sol;
	if(l[0]==0){
		sol=n-2;
	}
	else{
		sol=n-1;
		swap(l[x[n-2]], l[y[n-2]]);
		swap(pos[l[x[n-2]]], pos[l[y[n-2]]]);
		p[n-2]=0;
		if(l[0]!=0){
			q[n-2]=1;
		}
		else{
			q[n-2]=0;
		}
	}
	return sol;
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:10:39: warning: unused parameter 'm' [-Wunused-parameter]
   10 | int findSwapPairs(int n, int l[], int m, int x[], int y[], int p[], int q[]){
      |                                   ~~~~^
# Verdict Execution time Memory Grader output
1 Failed 1 ms 288 KB MODEL SOLUTION IS WRONG
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 288 KB MODEL SOLUTION IS WRONG
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 288 KB MODEL SOLUTION IS WRONG
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -