Submission #1302539

#TimeUsernameProblemLanguageResultExecution timeMemory
1302539nathlol2Sorting (IOI15_sorting)C++20
0 / 100
5 ms340 KiB
#include <bits/stdc++.h> #include "sorting.h" using namespace std; int findSwapPairs(int N, int a[], int M, int X[], int Y[], int P[], int Q[]) { swap(a[0], a[1]); for(int i = 0;i<N;i++){ if(a[i] == 1){ if(a[0] != 1){ swap(a[0], a[i]); P[0] = 0; Q[0] = i; }else{ swap(a[1], a[i]); P[0] = 1; Q[0] = i; } } } swap(a[0], a[1]); for(int i = 0;i<N;i++){ if(a[i] == 0){ if(i < 2){ P[1] = 0; Q[1] = 0; }else if(a[0] != 0){ swap(a[0], a[i]); P[1] = 0; Q[1] = i; }else{ swap(a[1], a[i]); P[1] = 1; Q[1] = i; } } } int k = 2; for(int i = 2;i < N - 1;i++){ int id = i; for(int j = i + 1;j < N;j++){ if(a[j] < a[id]) id = j; } if(id != i){ swap(a[i], a[id]); P[k] = i; Q[k] = id; k++; } } if(a[0] == 0 && a[1] == 1) return k; else{ P[k] = 0; Q[k] = 0; return k + 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...