Submission #238632

#TimeUsernameProblemLanguageResultExecution timeMemory
238632crossing0verSorting (IOI15_sorting)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
//#include "sorting.h"

using namespace std;
int n,a[10000],b[10000];

int findSwapPairs(int N1, int S1[], int m, int X[], int Y[], int P[], int Q[]) {
	n = N1;
	for (int i = 0; i <n ;i++) {
		a[i] = S1[i];
	}
	for (int i = 0; i < m ;i++) {
		swap(a[X[i]],a[Y[i]]);	
	}
	for (int i = 0; i < n; i++) {
		b[a[i]] = i;
	}
	vector<pair<int,int> > ans;
	
	for (int i = 0; i < n; i++) {
		int j = i;
		while (j && a[j] < a[j-1]) {
			swap(a[j],a[j-1]);
			ans.push_back({a[j],a[j-1]});
			j--;
		}
	}
	for (int i = 0; i < n; i++) {
		b[S1[i]] = i;
	}
	for (int i = 0; i < m; i++) ans.push_back({0,0});
	for (int i = 0; i < m; i++) {
		swap(S1[X[i]],S1[Y[i]]);
		b[S1[X[i]]] = X[i];
		b[S1[Y[i]]] = Y[i];
		swap(S1 [ b[ans[i].first]], S1[ b[ans[i].second ] ]);
		P[i] =  b[ans[i].first];
		Q[i] =  b[ans[i].second];
		swap(b[ans[i].first], b[ans[i].second ]);
		
	}
	return m;
}
main(){
	
}

Compilation message (stderr)

sorting.cpp:44:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
/tmp/ccYlkZEq.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/ccByvzdQ.o:sorting.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status