Submission #1037975


Source Code Expand

#include "bits/stdc++.h"

using namespace std;

#define int long long
#define PB push_back
#define ALL(V) V.begin(), V.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;

constexpr int INF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 5000;

pii d[MAX_N * 2];

void Print(int k) {
    if (4095 <= k) return;
    Print(k * 2 + 1);
    cout << d[k].first << " " << d[k].second << endl;
    Print(k * 2 + 2);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int idx = 0, cnt = 1;
    for (int i = 0; i <= 11; ++i) {
        for (int j = 0; j < cnt; ++j) {
            if (j < cnt / 2) {
                d[idx + j] = { 11 - i, j };
            } else {
                d[idx + j] = { 11 + i, j - (cnt / 2) };
            }
        }
        idx += cnt;
        cnt *= 2;
    }

    Print(0);
}

Submission Info

Submission Time
Task B - Binary Tree
User narerusyumi
Language C++14 (GCC 5.4.1)
Score 24
Code Size 925 Byte
Status AC
Exec Time 20 ms
Memory 384 KiB

Judge Result

Set Name All
Score / Max Score 24 / 100
Status
AC × 1
Set Name Test Cases
All 1.txt
Case Name Status Exec Time Memory
1.txt AC 20 ms 384 KiB