| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 587200 | M_W | Swap (BOI16_swap) | C++17 | 1 ms | 316 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ar array<int, 3>
using namespace std;
int a[200002];
ar find_min(int a, int b, int c){
vector<ar> tmp;
tmp.push_back({a, b, c});
tmp.push_back({b, a, c});
tmp.push_back({c, a, b});
tmp.push_back({c, b, a});
sort(tmp.begin(), tmp.end());
return tmp[0];
}
int main(){
int N;
scanf("%d", &N);
for(int i = 1; i <= N; i++) scanf("%d", &a[i]);
a[N + 1] = INT_MAX;
for(int i = 1; i * 2 <= N; i++){
ar tmp;
if(i * 2 + 1 > N) tmp = find_min(a[i], a[i * 2], max(a[i], a[i * 2]));
else tmp = find_min(a[i], a[i * 2], a[i * 2 + 1]);
int nxt1 = min(a[min(N + 1, (i * 2) * 2)], a[min(N + 1, (i * 2) * 2 + 1)]);
int nxt2 = min(a[min(N + 1, (i * 2 + 1) * 2)], a[min(N + 1, (i * 2 + 1) * 2 + 1)]);
if(tmp[0] == a[i * 2 + 1]){
if(nxt1 < tmp[1] && nxt2 >= tmp[1]) swap(tmp[1], tmp[2]);
}
a[i] = tmp[0]; a[i * 2] = tmp[1]; a[i * 2 + 1] = tmp[2];
}
for(int i = 1; i <= N; i++) printf("%d ", a[i]);
}컴파일 시 표준 에러 (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... | ||||
