제출 #1247086

#제출 시각아이디문제언어결과실행 시간메모리
1247086lrnnzSorting (IOI15_sorting)C++20
36 / 100
1 ms328 KiB
#include <bits/stdc++.h> #include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <iomanip> #include <queue> #include <random> #include "sorting.h" using namespace std; #define all(a) (a).begin(), (a).end() #define ll long long #define ld long double #define ui uint64_t #define cont(set, element) ((set).find(element) != (set).end()) #define pb push_back #define chmin(x, y) (x = min(x, y)) #define chmax(x, y) (x = max(x, y)) /********* DEBUG *********/ template <typename T> void outvec(const vector<T>& Z){ for (const T& x : Z) cout << x << ' '; cout << "\n"; } void printVariable(const any& var) { if (!var.has_value()) { cout << "null"; return; } if (var.type() == typeid(int)) { cout << any_cast<int>(var); } else if (var.type() == typeid(double)) { cout << any_cast<double>(var); } else if (var.type() == typeid(float)) { cout << any_cast<float>(var); } else if (var.type() == typeid(char)) { cout << any_cast<char>(var); } else if (var.type() == typeid(bool)) { cout << (any_cast<bool>(var) ? "true" : "false"); } else if (var.type() == typeid(string)) { cout << any_cast<string>(var); } else if (var.type() == typeid(const char*)) { cout << any_cast<const char*>(var); } else if (var.type() == typeid(long long)) { cout << any_cast<long long>(var); } else { cout << "[unknown type]"; } } template<typename... Args> void outval(Args... args) { vector<any> variables = {args...}; for (size_t i = 0; i < variables.size(); ++i) { printVariable(variables[i]); if (i != variables.size() - 1) { cout << " "; } } cout << "\n"; } #define sp << " " << #define fi first #define se second /********* DEBUG *********/ const ll MOD2 = 1e9 + 7; const ll MOD = 998244353; const ll inf = 1e18; int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) { vector<ll> place(N); for (int i = 0; i < N; i++){ place[S[i]] = i; } int p = 0, ans = 0, i = N-1; while (i >= 0 && S[i] == i) i--; if (i == -1) return 0; while (i >= 0){ // Ermek's swap ll x = X[p], y = Y[p]; swap(place[S[x]], place[S[y]]); swap(S[x], S[y]); ans++; P[p] = i; Q[p++] = place[i]; ll other = S[i]; swap(S[place[i]], S[i]); swap(place[other], place[i]); while (i >= 0 && S[i] == i) i--; } if (S[0] == 1){ ans++; P[p] = 0; Q[p] = 1; } return ans; }
#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...