# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
571878 | 2022-06-03T03:35:45 Z | kwongweng | Sorting (IOI15_sorting) | C++17 | 1 ms | 340 KB |
#include "sorting.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef long long ll; typedef long double ld; #define FOR(i,a,b) for(int i = a; i < b; i++) #define ROF(i,a,b) for(int i = a; i >= b; i--) #define fi first #define se second #define pb push_back int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { int pos[N]; FOR(i,0,N){ pos[S[i]] = i; } if (X[0] == Y[0]){ FOR(i,0,N-1){ P[i] = pos[i]; Q[i] = i; swap(pos[S[P[i]]], pos[S[Q[i]]]); swap(S[P[i]], S[Q[i]]); } return N-1; } FOR(i,0,N-1){ swap(pos[S[X[i]]], pos[S[Y[i]]]); swap(S[X[i]], S[Y[i]]); if (i == N-2){ if (S[0] == 0){ P[i] = 0; Q[i] = 0; }else{ P[i] = 0, Q[i] = 1; } swap(pos[S[P[i]]], pos[S[Q[i]]]); swap(S[P[i]], S[Q[i]]); break; } P[i] = pos[i+2]; Q[i] = i+2; swap(pos[S[P[i]]], pos[S[Q[i]]]); swap(S[P[i]], S[Q[i]]); } return N-1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 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 | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |