# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
793658 | Jarif_Rahman | Sorting (IOI15_sorting) | C++17 | 1 ms | 340 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>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[]){
vector<int> pos(n);
for(int i = 0; i < n; i++) pos[S[i]] = i;
int ans = 0;
for(int i = 2; i < n; i++){
if(i == S[i]) continue;
swap(S[0], S[1]);
swap(pos[S[0]], pos[S[1]]);
P[ans] = i, Q[ans] = pos[i];
ans++;
swap(pos[S[i]], pos[i]);
swap(S[i], S[pos[S[i]]]);
}
if(S[0] != 0) P[ans] = 0, Q[ans] = 0, ans++;
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |