# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
887257 | vjudge1 | Swap (BOI16_swap) | C++17 | 125 ms | 49220 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, a[N];
unordered_map<int, int> mp[N];
int ind(int v, int x) {
if (mp[v].find(x) != mp[v].end()) return mp[v][x];
if (v * 2 > n) return mp[v][x] = v;
if (x < a[v * 2] && x < a[v * 2 + 1]) return mp[v][x] = v;
if (a[v * 2] < x && a[v * 2] < a[v * 2 + 1]) return mp[v][x] = ind(v * 2, x);
else {
int mn = min(x, a[v * 2]), mx = max(x, a[v * 2]);
if (ind(v * 2, mn) < ind(v * 2 + 1, mn))
if (x == mn) return mp[v][x] = ind(v * 2, x);
else return mp[v][x] = ind(v * 2 + 1, x);
else
if (x == mn) return mp[v][x] = ind(v * 2 + 1, x);
else return mp[v][x] = ind(v * 2, x);
}
}
int main() {
ios:: sync_with_stdio(0), cin.tie(0);
cin >> n;
memset(a, 63, sizeof a);
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; 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... |