Submission #1355071

#TimeUsernameProblemLanguageResultExecution timeMemory
1355071yogesh_saneSorting (IOI15_sorting)C++20
16 / 100
13 ms484 KiB
#include <bits/stdc++.h>
using namespace std;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    vector<int>pos(N);
    for(int i = 0; i < M; i++){
        iota(pos.begin(), pos.end(), 0);
        for(int j = i+1; j < M; j++)
            swap(pos[X[j]], pos[Y[j]]);
        swap(S[X[i]], S[Y[i]]);            
        for(int j = 0; j < N; j++){
            if(S[pos[j]] != j){
                int k = find(S, S+N, j)-S;
                P[i] = pos[j];
                Q[i] = k;
                swap(S[pos[j]], S[k]);
                break;
            }
        }
    }
    return M;
}
#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...