| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1099105 | vjudge1 | Rack (eJOI19_rack) | C++17 | 84 ms | 102400 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
struct Node
{
int value;
Node* right;
Node* left;
Node(int val) : value(val), left(nullptr), right(nullptr) {}
};
class Tree
{
public:
Node* root;
Tree(int height) {
root = nullptr;
int leafValue = 0;
build(root, height, leafValue);
}
void build(Node*& node, int height, int& leafValue) {
if(height == 0) return;
node = new Node(0);
build(node -> left, height -1, leafValue);
build(node -> right, height -1, leafValue);
if (height == 1) { leafValue++; node -> value = leafValue; }
}
int traverse(vector<int> path, int height) {
Node* current = root;
for (int i = 0; i < height; ++i) {
current = (path[i] == 0) ? current->left : current->right;
}
return current ? current -> value : -1;
}
};
int main()
{
int height, node;
cin >> height >> node;
int rows = 1 << height;
Tree tree(height + 1);
std::vector<int> path(height);
for (int i = 0; i < node; ++i) {
for (int j = 0; j < height; ++j) path[j] = (i >> j) & 1;
}
cout << tree.traverse(path, height) << endl;
return 0;
}
컴파일 시 표준 에러 (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... | ||||
