# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587514 | benson1029 | Sorting (IOI15_sorting) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
int a[200005], b[200005], s[200005];
void swapa(int x, int y) {
b[a[x]] = y;
b[a[y]] = x;
if(st.find(x)==st.end() && st.find(y)!=st.end()) {
st.erase(y);
st.insert(x);
}
else if(st.find(x)!=st.end() && st.find(y)==st.end()) {
st.erase(x);
st.insert(y);
}
swap(a[x], a[y]);
}
vector< pair<int,int> > v;
set<int> st;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
int l = 0, r = N, mid;
while(l <= r) {
mid = (l+r)/2;
for(int i=0; i<N; i++) {