# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
552894 | elazarkoren | 정렬하기 (IOI15_sorting) | C++17 | 2 ms | 468 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
//#define int ll
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<bool> vb;
const int MAX_N = 2e5 + 5;
int x[MAX_N], y[MAX_N];
int n;
int cnt;
vi Compute(int i, vi s) {
for (; i < cnt; i++) {
swap(s[x[i]], s[y[i]]);
}
return s;
}
int findSwapPairs(int N, int S[], int m, int X[], int Y[], int p[], int q[]) {
n = N;
cnt = n;
vi s(n);
for (int i = 0; i < n; i++) s[i] = S[i];
for (int i = 0; i < cnt; i++) x[i] = X[i], y[i] = Y[i];
for (int i = 0; i < n; i++) {
swap(s[x[i]], s[y[i]]);
vi s2 = s;
if (s2[i] != i) {
for (int j = i; j < n; j++) {
if (s2[j] == i) {
p[i] = i, q[i] = j;
swap(s[i], s[j]);
break;
}
}
} else {
p[i] = q[i] = 0;
}
if (is_sorted(all(s))) {
cnt = i + 1;
break;
}
}
return cnt;
}
//8
//3 5 6 2 1 7 0 4
//8
//0 1
//0 1
//0 1
//0 1
//0 1
//0 1
//0 1
//0 1
//5
//3 2 1 0 4
//5
//0 0
//0 0
//0 0
//0 0
//0 0
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |