Submission #1195156

#TimeUsernameProblemLanguageResultExecution timeMemory
1195156nikulidSorting (IOI15_sorting)C++20
0 / 100
1 ms328 KiB
#include "sorting.h"
#include <vector>

using namespace std;

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
    bool already_sorted;
    // we are given S[], M, X[], Y[]
    // we are to give P[], Q[]
    vector<int> ns;
    for(int i=0; i<N; i++){
    	ns.push_back(S[i]);
    }
    for(int i=0; i<N; i++){
    	P[i] = i;
    	Q[i] = ns[i];
    	swap(ns[i], ns[ns[i]]);
    	already_sorted=true;
    	for(int j=1; j<N; j++){
    		if(ns[j-1] > ns[j]){
    			already_sorted=false;
    			break;
    		}
    	}
    	if(already_sorted){
    		return i+1;
    	}
    }
	return N;
}

// 3 2 5 1 4

// -op1
// 1 2 5 3 4

// -op2
// 1 2 5 3 4

// -op3
// 1 2 3 5 4

// -op4
// 1 2 3 4 5

// -op5

// 
#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...