# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
790143 | PoonYaPat | Sorting (IOI15_sorting) | C++14 | 46 ms | 500 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 pair<int,int> pii;
int n,m,b[200005],x[200005],y[200005],p[200005];
vector<pii> ans;
int a[200005],pos[200005],val[200005],c[200005];
bool check(int h, bool mode) {
for (int i=0; i<n; ++i) a[i]=i, val[i]=i, c[i]=b[i], p[i]=i;
for (int i=h; i>=0; --i) swap(a[x[i]],a[y[i]]);
vector<pii> v;
for (int i=0; i<n; ++i) pos[c[i]]=i;
for (int i=0; i<n; ++i) {
if (c[i]!=a[i]) {
v.push_back(pii(i,pos[a[i]]));
swap(pos[a[i]],pos[c[i]]);
swap(c[pos[c[i]]],c[i]);
}
}
reverse(v.begin(),v.end());
if (mode) {
for (int i=0; i<=h; ++i) {
swap(val[p[x[i]]],val[p[y[i]]]);
swap(p[x[i]],p[y[i]]);
if (v.size()) {
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... |