Submission #100612

# Submission time Handle Problem Language Result Execution time Memory
100612 2019-03-12T20:37:14 Z luciocf Sorting (IOI15_sorting) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
#include "sorting.h"

using namespace std;

const int maxn = 2e5+10;

int pos[maxn];

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

    if (Y[0] == 0)
    {   
        P[0] = 0, Q[0] = 0;
        return 1;
        for (int i = 0; i < N; i++)
        {
            int j = S[i];

            P[i] = pos[i], Q[i] = i;

            S[pos[i]] = j, S[i] = i;

            pos[j] = pos[i], pos[i] = i;
        }

        return N;
    }

    pos[S[0]] = 1, pos[S[1]] = 0;
    swap(S[0], S[1]);

    int j = S[1];

    P[0] = pos[0], Q[0] = 1;

    S[pos[0]] = j, S[1] = 0;

    pos[j] = pos[0], pos[0] = 1;

    pos[S[0]] = 1, pos[S[1]] = 0;
    swap(S[0], S[1]);

    j = S[1];

    P[1] = pos[1], Q[1] = 1;

    S[pos[1]] = j, S[1] = 1;

    pos[j] = pos[1], pos[1] = 1;

    for (int i = 2; i < N; i++)
    {
        j = S[i];

        P[i] = pos[i], Q[i] = i;

        S[pos[i]] = j, S[i] = i;

        pos[j] = pos[i], pos[i] = i;
    }

    if (N&1)
    {
        P[N] = 0, Q[N] = 0;
        return N+1;
    }

    return N;
}

Compilation message

sorting.cpp: In function 'int findSwapPairs(int, int*, int, int*, int*, int*, int*)':
sorting.cpp:10:39: warning: unused parameter 'M' [-Wunused-parameter]
 int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) 
                                       ^
sorting.cpp:10:48: warning: unused parameter 'X' [-Wunused-parameter]
 int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) 
                                                ^
# 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 2 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 2 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 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -