Submission #1088687

# Submission time Handle Problem Language Result Execution time Memory
1088687 2024-09-14T19:03:36 Z gustavo_d Sorting (IOI15_sorting) C++17
54 / 100
10 ms 664 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[]
) {
	if (N == 1) return 0;

    for (int t=0; t<N; t++) {
		for (int i=1; i<N; i++) {
			if (S[i] < S[i-1]) break;
			if (i == N-1) return t;
		}
		swap(S[X[t]], S[Y[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;
    }
    // cout << "ans = ";
    // for (int i=0; i<N; i++) cout << S[i] << ' ';
    // cout << endl;

    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 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 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 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 8 ms 664 KB Output is correct
22 Correct 8 ms 600 KB Output is correct
23 Correct 9 ms 604 KB Output is correct
24 Correct 8 ms 600 KB Output is correct
25 Correct 9 ms 600 KB Output is correct
26 Correct 8 ms 660 KB Output is correct
27 Correct 8 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 552 KB Output isn't correct
2 Halted 0 ms 0 KB -