Submission #238630

# Submission time Handle Problem Language Result Execution time Memory
238630 2020-06-12T08:28:22 Z crossing0ver Sorting (IOI15_sorting) C++17
0 / 100
21 ms 8816 KB
#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 1;
}


# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 8816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 8816 KB Output isn't correct
2 Halted 0 ms 0 KB -