Submission #1291184

#TimeUsernameProblemLanguageResultExecution timeMemory
1291184kustov_vadim_533Sorting (IOI15_sorting)C++20
16 / 100
7 ms572 KiB
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <queue>
#include <array>
#include <map>
#include <random>
#include <bitset>
#include <stack>
#include <deque>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <chrono>
//#include "towns.h"

using namespace std;

typedef long long ll;
typedef long double ld;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
	for (int i = 0; i < M; ++i) {
		bool fl = true;
		for (int j = 0; j < N; ++j) {
			fl = fl && (S[j] == j);
		}
		if (fl) return i;

		swap(X[i], Y[i]);

		P[i] = 0;
		Q[i] = 0;

		if (i % 2 == 0) continue;

		for (int j = 0; j < N; ++j) {
			if (S[j] != j) {
				P[i] = j;
				Q[i] = S[j];
				swap(S[j], S[S[j]]);
				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...