# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830422 | 2023-08-19T06:24:02 Z | mindiyak | Sorting (IOI15_sorting) | C++17 | 4 ms | 340 KB |
#include "sorting.h" #include <queue> #include <vector> #include <iostream> using namespace std; void print(int N,int A[]){ // for(int i=0;i<N;i++)cout << A[i] << " "; // cout << endl; } int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int R=0; int sorted = 0; for(int i=0;i<N;i++)if(S[i] == i)sorted++; print(N,S); // cout << sorted << endl; while(sorted<N){ int dual = -1; int pos = -1; for(int i=0;i<N;i++){ if(S[i] == i)continue; if(S[i] != i)pos = i; // cout << i << " " << S[i] << " " << S[S[i]] << endl; if(i == S[S[i]]){ dual = 1; break; } } sorted += 1; P[R] = pos; Q[R] = S[pos]; // cout << "swap " << dual << " " << P[R] << " " << Q[R] << endl; if(dual == 1){ sorted += 1; } swap(S[P[R]],S[Q[R]]); R++; print(N,S); } return R; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 296 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Incorrect | 0 ms | 340 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 296 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Incorrect | 0 ms | 340 KB | Output isn't correct |
17 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |