# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
291539 | MarcoMeijer | 정렬하기 (IOI15_sorting) | C++14 | 7 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include "sorting.h"
//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
#define sz size()
const int MX = 2e5+100;
int a[MX], sa[MX];
void swapA(int x, int y) {
swap(a[x], a[y]);
sa[a[x]] = x;
sa[a[y]] = y;
}
int findSwapPairs(int n, int S[], int m, int X[], int Y[], int P[], int Q[]) {
RE(i,n) a[i]=sa[i]=i;
RE(i,n) {
swapA(sa[X[i]], sa[Y[i]]);
}
int R = 0;
RE(i,n) {
bool sorted = 1;
RE(i,n) if(S[i] != i) sorted = 0;
if(sorted) break;
R++;
swapA(X[i], Y[i]);
swap(S[X[i]], S[Y[i]]);
int x=0, y=0; i--;
while(x == y) {
i++;
if(i == n) break;
RE(j,n) if(S[j] == i) x = j;
RE(j,n) if(j == i) y = j;
}
swap(S[x], S[y]);
P[R-1] = x;
Q[R-1] = y;
}
return R;
}
컴파일 시 표준 에러 (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... |