# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140545 | SirCeness | Sorting (IOI15_sorting) | C++14 | 8 ms | 504 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 mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define orta ((l+r)>>1)
#define INF 1000000009
#define mod 1000000007
#define ppair(x) "(" << x.first << ", " << x.second << ") "
#define bas(x) #x << ": " << x << " "
#define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n";
#define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n";
using namespace std;
typedef long long ll;
int n, m;
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
n = N; m = M;
vector<int> sanal;
for (int i = 0; i < n; i++) sanal.pb(S[i]);
for (int i = 0; i < m; i++) swap(sanal[X[i]], sanal[Y[i]]);
vector<int> sim;
for (int i = 0; i < n; i++) sim.pb(S[i]);
//prarrv(sanal);
vector<pair<int, int> > deg;
for (int i = 0; i < n; i++){
if (sanal[i] != i){
for (int j = i+1; j < n; j++){
if (sanal[j] == i){
deg.pb(mp(sanal[i], sanal[j]));
swap(sanal[i], sanal[j]);
break;
}
}
}
}
//for (int i = 0; i < deg.size(); i++) cout << ppair(deg[i]) << " "; cout << endl;
int r = deg.size();
for (int i = 0; i < M; i++){
swap(S[X[i]], S[Y[i]]);
if (i >= r){
P[i] = 0;
Q[i] = 0;
continue;
}
for (int j = 0; j < n; j++){
if (S[j] == deg[i].first) P[i] = j;
if (S[j] == deg[i].second) Q[i] = j;
}
swap(S[P[i]], S[Q[i]]);
}
/*prarrv(sim);
for (int i = 0; i < m; i++){
swap(sim[X[i]], sim[Y[i]]);
prarrv(sim);
swap(sim[P[i]], sim[Q[i]]);
prarrv(sim);
}*/
return M;
}
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... |