Submission #1053703

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

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, vi, int, vi, vi, vi, vi)':
sorting.cpp:5:36: warning: unused parameter 'm' [-Wunused-parameter]
    5 | int findSwapPairs(int n, vi s, int m, vi x, vi y, vi p, vi q) {
      |                                ~~~~^
sorting.cpp:5:42: warning: unused parameter 'x' [-Wunused-parameter]
    5 | int findSwapPairs(int n, vi s, int m, vi x, vi y, vi p, vi q) {
      |                                       ~~~^
/usr/bin/ld: /tmp/ccdrYU40.o: in function `main':
grader.c:(.text.startup+0x4eb): undefined reference to `findSwapPairs(int, int*, int, int*, int*, int*, int*)'
collect2: error: ld returned 1 exit status