# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
288363 | Saboon | 정렬하기 (IOI15_sorting) | C++17 | 272 ms | 28024 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, x[3*maxn], y[3*maxn], a[maxn], b[maxn], pos[maxn], mex[3*maxn], mey[3*maxn];
bool mark[maxn];
bool check(int Q){
for (int i = 0; i < n; i++){
b[i] = a[i];
pos[a[i]] = i;
}
for (int i = 0; i < Q; i++)
swap(a[x[i]], a[y[i]]);
int cnt = 0;
memset(mark, 0, sizeof mark);
for (int i = 0; i < n; i++){
int now = i;
mark[now] = 1;
while (!mark[a[now]]){
int last = now;
now = a[now];
mark[now] = 1;
swap(b[x[cnt]], b[y[cnt]]);
swap(pos[b[x[cnt]]], pos[b[y[cnt]]]);
mex[cnt] = pos[now], mey[cnt] = pos[last];
swap(pos[now],pos[last]);
swap(b[pos[now]], b[pos[last]]);
cnt ++;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |