Submission #31815

# Submission time Handle Problem Language Result Execution time Memory
31815 2017-09-10T10:52:00 Z top34051 Sorting (IOI15_sorting) C++14
0 / 100
17 ms 468 KB
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005

int a[maxn], pos[maxn];

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    int i,x,now,cnt;
    for(now=0;now<M;now++) {
        swap(S[X[now]], S[Y[now]]);

        for(i=0;i<N;i++) a[i] = S[i];
        for(i=0;i<N;i++) pos[a[i]] = i;

        cnt = 0;
        for(i=0;i<N;i++) {
            x = pos[i];
            if(i!=x) {
                pos[a[i]] = x;
                swap(a[i], a[x]);
                P[cnt] = i; Q[cnt] = x;
                cnt++;
            }
        }
        while(cnt<now+1) P[cnt] = Q[cnt] = 0, cnt++;

        if(cnt<=now+1) return now+1;
    }
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:30:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -