| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 134252 | Kastanda | Swap (BOI16_swap) | C++11 | 90 ms | 6776 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// ItnoE
#include<bits/stdc++.h>
using namespace std;
const int N = 400005;
int n, A[N], R[N], M[N];
inline int GetBest(int id)
{
int Mn = INT_MAX;
while (id)
{
if (M[id] != 1)
Mn = min(Mn, A[id]);
if (!M[id])
break;
if ((id & 1) && M[id ^ 1])
{
Mn = min(Mn, A[id ^ 1]);
if (M[id ^ 1] == 1)
break;
}
id >>= 1;
}
return (Mn);
}
inline void Del(int id, int val)
{
while (id)
{
if (A[id] == val)
{M[id] = 0; break;}
if (id & 1)
{
if (A[id ^ 1] == val)
{M[id ^ 1] = M[id] = 1; break;}
else
M[id ^ 1] = 0;
}
M[id] = 1;
id >>= 1;
}
}
int main()
{
scanf("%d", &n);
memset(A, 63, sizeof(A));
for (int i = 1; i <= n; i ++)
scanf("%d", &A[i]), M[i] = 2;
M[1] = 0;
for (int i = 1; i <= n; i ++)
{
int lc = i << 1, rc = lc ^ 1;
int Mn = min({GetBest(i), A[lc], A[rc]});
R[i] = Mn;
if (Mn == GetBest(i))
M[lc] = M[rc] = 0, Del(i, Mn);
if (Mn == A[lc])
M[lc] = 1, M[rc] = 0;
if (Mn == A[rc])
M[rc] = 1;
}
for (int i = 1; i <= n; i ++)
printf("%d ", R[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... | ||||
