Submission #621007

# Submission time Handle Problem Language Result Execution time Memory
621007 2022-08-03T11:02:22 Z Hazem Sorting (IOI15_sorting) C++14
0 / 100
4 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=2;j<n;j++)
			if(i==j)
				continue;
			else 
			if(S[j]==i){
				P[cur] = i;
				Q[cur] = j;
				cur++;
				swap(S[i],S[j]);
				swap(S[0],S[1]);
			}

	if(S[0]>S[1]){
		P[cur] = Q[cur] = 0;
		cur++;
	}
	

	return cur;
}


Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
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[]) {
      |                                          ~~~~^~~
sorting.cpp:5:55: warning: unused parameter 'Y' [-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 1 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Integer 1 violates the range [0, 0]
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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 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 1 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -