제출 #861300

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
8613002023-10-15 23:17:31pedroslrey정렬하기 (IOI15_sorting)C++14
54 / 100
201 ms956 KiB
#include <bits/stdc++.h>
#include "sorting.h"
using namespace std;
bool check(int n, int xs[], int k, int ss1[], int ss2[], int ans1[] = nullptr, int ans2[] = nullptr) {
vector<int> ideal(n), idealrev(n), ys(n), ysrev(n);
for (int i = 0; i < n; ++i)
ideal[i] = idealrev[i] = ysrev[ys[i] = xs[i]] = i;
for (int i = k-1; i >= 0; --i) {
swap(ideal[ss1[i]], ideal[ss2[i]]);
swap(idealrev[ideal[ss1[i]]], idealrev[ideal[ss2[i]]]);
}
int lst = 0;
for (int i = 0; i < k; ++i) {
swap(ideal[ss1[i]], ideal[ss2[i]]);
swap(idealrev[ideal[ss1[i]]], idealrev[ideal[ss2[i]]]);
swap(ys[ss1[i]], ys[ss2[i]]);
swap(ysrev[ys[ss1[i]]], ysrev[ys[ss2[i]]]);
cerr << "-> " << lst << " " << idealrev[lst] << " " << ysrev[lst] << "\n";
while (lst < n && idealrev[lst] == ysrev[lst]) ++lst;
if (lst < n) {
int a = ysrev[lst], b = idealrev[lst];
swap(ys[a], ys[b]);
swap(ysrev[ys[a]], ysrev[ys[b]]);
if (ans1 != nullptr) { ans1[i] = a; ans2[i] = b; }
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...