Submission #620983

# Submission time Handle Problem Language Result Execution time Memory
620983 2022-08-03T10:51:28 Z Hazem Sorting (IOI15_sorting) C++14
0 / 100
5 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	
	int n = N;
	int cur = 0;

	swap(S[0],S[1]);
	for(int i=0;i<n;i++)
		if(S[i]==0){
			P[cur] = 1;
			Q[cur] = i;
			cur++;
			swap(S[i],S[1]);
		} 
	
	
	swap(S[0],S[1]);
	for(int i=0;i<n;i++)
		if(S[i]==1){
			P[cur] = 1;
			Q[cur] = i;
			cur++;
			swap(S[i],S[1]);
		} 
	

	for(int i=2;i<n;i++)
		for(int j=0;j<n;j++)
			if(i==j)
				continue;
			else 
			if(S[j]==i){
				P[cur] = i;
				Q[cur] = j;
				cur++;
				swap(S[i],S[j]);
				if(Y[0])
					swap(S[0],S[1]);
			}

	bool q = 1;
	if((cur&1)){
		swap(S[0],S[1]);
		P[cur] = 0;
		Q[cur] = 0;
		cur++;
	}

	return cur;
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:44:7: warning: unused variable 'q' [-Wunused-variable]
   44 |  bool q = 1;
      |       ^
sorting.cpp:5:39: warning: unused parameter 'M' [-Wunused-parameter]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                   ~~~~^
sorting.cpp:5:46: warning: unused parameter 'X' [-Wunused-parameter]
    5 | int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
      |                                          ~~~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer parameter [name=R] equals to 2, violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer parameter [name=R] equals to 2, violates the range [0, 1]
2 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 340 KB Output is correct
5 Incorrect 0 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer parameter [name=R] equals to 2, violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -