# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155092 | dennisstar | Sorting (IOI15_sorting) | C++11 | 756 ms | 25052 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 *s, *x, *y, *p, *q;
int ans;
int n, m;
int A[200010], B[200010], posB[200010], F[200010], posF[200010];
//현재 에르맥, 현재 수열, 현재 수열의 pos, 결과 수열, 결과 수열의 pos
int seq[600010][2], tp;
bool canSwap(int l)
{
int i; tp=0;
for (i=0; i<n; i++) A[i]=i, B[i]=s[i], posB[s[i]]=i, F[i]=s[i], posF[s[i]]=i;
for (i=0; i<l; i++) {
swap(F[x[i]], F[y[i]]);
swap(posF[F[x[i]]], posF[F[y[i]]]);
}
for (i=l-1; i>=0; i--) swap(A[x[i]], A[y[i]]);
while (tp<n&&F[tp]==tp) tp++;
for (i=0; i<l; i++) {
swap(A[x[i]], A[y[i]]);
swap(B[x[i]], B[y[i]]);
swap(posB[B[x[i]]], posB[B[y[i]]]);
int i1=F[tp], i2=F[posF[tp]];
swap(F[tp], F[posF[tp]]);
swap(posF[i1], posF[i2]);
seq[i][0]=posB[i1], seq[i][1]=posB[i2];
swap(B[posB[i1]], B[posB[i2]]);
swap(posB[i1], posB[i2]);
//for (int j=0; j<n; j++) printf("%d ", A[j]); puts("");
# | 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... |