Submission #1337160

#TimeUsernameProblemLanguageResultExecution timeMemory
1337160tsetsenbileg정렬하기 (IOI15_sorting)C++20
0 / 100
20 ms25868 KiB
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
using ll = long long;
using ld = long double;
using pr = pair<int, int>;
const int MOD = 1e9+7, MAXA = 1e6;

int findSwapPairs(int n, int s[], int m, int x[], int y[], int p[], int q[]) {
	vector<int> cur(n);
	for (int i = 0; i < n; i++) cur[i] = i;
	vector<vector<int>> srt(n), poss(n, vector<int>(n));
    for (int i = n-2; i >= 0; i--) {
		swap(cur[x[i]], cur[y[i]]);
		srt[i] = cur;
		for (int j = 0; j < n; j++) {
			poss[i][cur[j]] = j;
		}
	}
	vector<int> pos(n);
	for (int i = 0; i < n; i++) pos[s[i]] = i;
	for (int i = 0; i < n-1; i++) {
		p[i] = pos[i];
		q[i] = pos[poss[i][i]];
		swap(pos[i], pos[poss[i][i]]);
	}
	return n-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...