Submission #1053682

# Submission time Handle Problem Language Result Execution time Memory
1053682 2024-08-11T15:28:54 Z XJP12 Sorting (IOI15_sorting) C++14
0 / 100
2 ms 348 KB
#include <bits/stdc++.h>
#include "sorting.h"
using namespace std;
typedef vector<int> vi;
int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
	int r=0;
    if(y[0]==1){
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(s[j]==i && j!=i){
					p[i]=j;
					q[i]=i;
					swap(s[i], s[j]);
					r++;
					break;
				}
			}
			swap(s[1], s[0]);
		}
		if(s[1]!=1 && s[0]!=0){
			p[r]=0;
			q[r]=1;
			r++;
		}
	}else{
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if(s[j]==i && j!=i){
					p[i]=j;
					q[i]=i;
					swap(s[i], s[j]);
					r++;
					break;
				}
			}
		}
	}
	return r;
}

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[]) {
      |                                          ~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -