# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
790057 | peteza | Sorting (IOI15_sorting) | C++14 | 141 ms | 16624 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 <bits/stdc++.h>
#include "sorting.h"
using namespace std;
int cur[200005], N;
bool vis[200005];
int pos[200005];
int countcompo() {
for(int j=0;j<=N;j++) vis[j] = 0;
int cnt = 0;
for(int i=0;i<N;i++) {
if(vis[i]) continue;
vis[i] = 1;
cnt++;
int j=i;
do vis[j=cur[j]] = 1; while(j != i);
}
return cnt;
}
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
::N = N;
for(int i=0;i<N;i++) cur[i] = S[i];
memset(P, 0, 4*M); memset(Q, 0, 4 * M);
if(countcompo() == N) return 0;
int l=0, r=M;
while(l <= r) {
int mid = (l+r) >> 1;
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... |