# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
571890 | kwongweng | 정렬하기 (IOI15_sorting) | C++17 | 2 ms | 424 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define ROF(i,a,b) for(int i = a; i >= b; i--)
#define fi first
#define se second
#define pb push_back
int findSwapPairs(int N, int S[], int M, int X[], int Y[], int P[], int Q[]) {
int pos[N];
FOR(i,0,N){
pos[S[i]] = i;
}
vi s(N); FOR(i,0,N) s[i] = S[i];
if (X[0]==Y[0]){
int cnt = 0;
FOR(i,0,N-1){
if (pos[i] == i) continue;
P[cnt] = pos[i];
Q[cnt] = i;
cnt++;
s[pos[i]] = s[i];
pos[s[i]] = pos[i];
}
return cnt;
}
FOR(i,0,N-1){
if (X[i] != Y[i]){
swap(pos[S[X[i]]], pos[S[Y[i]]]);
swap(S[X[i]], S[Y[i]]);
}
if (i == N-2){
if (S[0] == 0){
P[i] = 0; Q[i] = 0;
}else{
P[i] = 0, Q[i] = 1;
}
if (P[i] != Q[i]){
swap(pos[S[P[i]]], pos[S[Q[i]]]);
swap(S[P[i]], S[Q[i]]);
}
break;
}
P[i] = pos[i+2];
Q[i] = i+2;
if (P[i] != Q[i]){
swap(pos[S[P[i]]], pos[S[Q[i]]]);
swap(S[P[i]], S[Q[i]]);
}
}
return N-1;
}
컴파일 시 표준 에러 (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... |