Submission #1088676

# Submission time Handle Problem Language Result Execution time Memory
1088676 2024-09-14T18:39:53 Z gustavo_d Sorting (IOI15_sorting) C++17
16 / 100
12 ms 552 KB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;

int findSwapPairs(
	int N, int S[], int M, int X[], int Y[], int P[], int Q[]
) {
    swap(S[X[0]], S[Y[0]]); // now is our turn
    for (int t=0; t<N; t++) {
    	int permut[N];
    	for (int i=0; i<N; i++) permut[i] = i;
    	for (int i=t+1; i<M; i++) {
    		swap(permut[X[i]], permut[Y[i]]);
    	}
    	int a=0, b=0;
    	for (int i=0; i<N; i++) {
    		if (S[i] == t) a = i;
    	}
    	b = permut[t];
    	swap(S[a], S[b]);
    	P[t] = a; Q[t] = b;
    	swap(S[X[t+1]], S[Y[t+1]]);
    }

    for (int t=N; t<M; t++) {
    	P[t] = Q[t] = 0;
    }
    return M;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 552 KB Output isn't correct
2 Halted 0 ms 0 KB -