# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083209 | Malix | Sorting (IOI15_sorting) | C++14 | 1 ms | 348 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;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pi;
typedef vector<pi> pii;
typedef tuple<int,int,int> tii;
typedef vector<ll> li;
typedef vector<li> lii;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define LSOne(s) ((s)&(-s))
ll INF=1000000000000000010;
int inf=1e9+10;
ll M=1e9+7;
int findSwapPairs(int n, int S[], int M, int X[], int Y[], int P[], int Q[]) {
vi a(n),b(n);
if(n==1)return 0;
int ans=0;
REP(i,0,n)a[S[i]]=i;
REP(i,0,n)b[i]=S[i];
int pos=0;
for(int i=n-1;i>=0;i--){
if(Y[0]==1){
swap(b[a[0]],b[a[1]]);
swap(a[0],a[1]);
if(i==0&&a[i]==i){
ans++;
P[pos]=0;
Q[pos]=0;
break;
}
}
if(a[i]==i)continue;
ans++;
P[pos]=i;
Q[pos]=a[i];
pos++;
swap(b[i],b[a[i]]);
int x=b[a[i]];
int y=a[i];
a[i]=i;
a[x]=y;
}
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... |