| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 405340 | Aryan_Raina | Poklon (COCI17_poklon7) | C++14 | 801 ms | 221680 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define ld long double
#define ar array
const int INF = 1e17;
const int MOD = 1e9+7;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int N; cin >> N;
vector<ar<int,2>> adj(N);
for (auto &i : adj) {
cin >> i[0] >> i[1];
if (i[0] > 0) --i[0];
if (i[1] > 0) --i[1];
}
vector<string> remdi;
function<int(int)> dfs = [&](int u)->int {
if (u < 0) {
remdi.push_back("");
for (int i = -u; i; i >>= 1) remdi.back() += '0' + (i & 1);
reverse(remdi.back().begin(), remdi.back().end());
return (int) remdi.size() - 1;
}
int lc = dfs(adj[u][0]), rc = dfs(adj[u][1]), ans = lc;
if (remdi[lc].size() == remdi[rc].size()) {
for (int i = 0; i < remdi[lc].size(); i++) {
if (remdi[lc][i] ^ remdi[rc][i]) {
ans = (remdi[lc][i] - '0') ? lc : rc;
break;
}
}
} else {
ans = (remdi[lc].size() > remdi[rc].size()) ? lc : rc;
}
remdi[ans] += '0';
return ans;
};
cout << remdi[dfs(0)] << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
