Submission #287475

#TimeUsernameProblemLanguageResultExecution timeMemory
287475AaronNaiduSorting (IOI15_sorting)C++14
0 / 100
8 ms768 KiB
#include <bits/stdc++.h> using namespace std; vector<int> s; int n; bool sorted() { for (int i = 0; i < n; i++) { if (s[i] != i) { return false; } } return true; } int findSwapPairs(int N,int S[],int M, int X[],int Y[], int P[],int Q[]) { for (int i = 0; i < M; i++) { P[i] = 0; Q[i] = 0; } n = N; for (int i = 0; i < N; i++) { s.push_back(S[i]); } for (int i = 0; i < N; i++) { if (sorted()) { return i; } swap(s[X[i]], s[Y[i]]); swap(S[X[i]], S[Y[i]]); for (int j = 0; j < N; j++) { if (S[j] == i) { P[i] = j; Q[i] = i; swap(s[j], s[i]); swap(S[j], S[i]); break; } if (j == N-1) { assert(false); } } } assert(sorted()); return N; }
#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...