| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 314880 | tengiz05 | Sorting (IOI15_sorting) | C++17 | 2 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "sorting.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int n, m;
int x[N], y[N], pos[N], a[N];
vector<pair<int, int>> v;
bool check(int mid){
v.clear();
for(int i=0;i<n;i++)pos[a[i]] = i;
vector<bool> used(n);
for(int i=0;i<mid;i++){
swap(pos[a[x[i]]], pos[a[y[i]]]);
swap(a[x[i]], a[y[i]]);
}int ans = 0;
for(int i=0;i<n;i++){
if(pos[i] == i){
continue;
}else {
ans++;
int f = pos[i], s = i;
swap(pos[i], pos[a[i]]);
swap(a[f], a[s]);
v.push_back({f, s});
}
}
return (ans <= mid);
}
int findSwapPairs(int NN, int A[], int MM, int X[], int Y[], int P[], int Q[]) {
n = NN, m = MM;
int l = 0, r = n;
for(int i=0;i<m;i++){
x[i] = X[i];
y[i] = Y[i];
}
while(l+1 < r){
for(int i=0;i<n;i++)a[i] = A[i];
int mid = (l+r)/2;
if(check(mid)){
r = mid;
}else {
l = mid;
}
}
check(r);
for(int i=0;i<r;i++){
if(i < v.size()){
P[i] = v[i].first;
Q[i] = v[i].second;
}else {
P[i] = Q[i] = 0;
}
}
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... | ||||
