| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 785678 | I_Love_EliskaM_ | 정렬하기 (IOI15_sorting) | C++14 | 1 ms | 724 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;++i)
#define pb push_back
int ok(vector<int>&a) {
forn(i,a.size()) if (a[i]!=i) return 0;
return 1;
}
struct DSU {
vector<int> p,sz;
DSU(int n) {
forn(i,n) p.pb(i), sz.pb(1);
}
int get(int u) {
return p[u]==u?u:get(p[u]);
}
void uni(int u, int v) {
u=get(u), v=get(v);
if (u==v) return;
if (sz[u]<sz[v]) swap(u,v);
sz[u]+=sz[v];
p[v]=u;
}
};
int findSwapPairs(int n, int _p[], int m, int _x[], int _y[], int p[], int q[]) {
vector<int> a;
forn(i,n) a.pb(_p[i]);
if (ok(a)) return 0;
vector<int> x,y;
forn(i,m) x.pb(_x[i]), y.pb(_y[i]);
x.pb(0), y.pb(0);
int z=1;
forn(i,m) z&=(x[i]==y[i])&&(x[i]==0);
if (z) {
int t=0;
while (!ok(a)) {
forn(i,n) {
if (a[i]!=i) {
p[t]=i, q[t]=a[i];
swap(a[i],a[a[i]]);
++t;
break;
}
}
}
return t;
}
z=1;
forn(i,m) z&=(x[i]==0) && (y[i]==1);
if (z) {
int t=0;
while(1) {
swap(a[0],a[1]);
int b=0;
vector<int> pos(n);
forn(i,n) pos[a[i]]=i;
forn(i,n) {
if (i<2) continue;
if (a[i]!=i) {
p[t]=i, q[t]=pos[i];
swap(a[i],a[pos[i]]);
++t;
b=1;
break;
}
}
if (b) continue;
if (ok(a)) {
p[t]=0, q[t]=0; ++t;
return t;
} else {
p[t]=0, q[t]=1; ++t;
return t;
}
}
return t;
}
exit(1);
return 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... | ||||
