Submission #988612

# Submission time Handle Problem Language Result Execution time Memory
988612 2024-05-25T09:51:58 Z vjudge1 Konstrukcija (COCI20_konstrukcija) C++17
0 / 110
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int n = 2;
vector<pair<int,int>> ans;

void build(vector<int> par, ll k, bool neg) {
    if (k == 1) {
        if (neg) {
            vector<int> newpar = {n + 1, n + 2};
            n += 2;
            for (auto &i : par) {
                for (auto &j : newpar) {
                    ans.emplace_back(i, j);
                }
            }
            build(newpar, 1, neg ^ 1);
            return;
        }
        for (auto &i : par) {
            ans.emplace_back(i, 2);
        }
        return;
    }
    vector<int> newpar = {n + 1, n + 2, n + 3};
    n += 3;
    for (auto &i : par) {
        for (auto &j : newpar) {
            ans.emplace_back(i, j);
        }
    }
    build(newpar, k >> 1, neg ^ 1);
    if (k & 1) {
        vector<int> newpar = {n + 1, n + 2};
        n += 2;
        for (auto &i : par) {
            for (auto &j : newpar) {
                ans.emplace_back(i, j);
            }
        }
        build(newpar, 1, neg ^ 1);
    }
}

void solve() {
    ll k;
    cin >> k;
    if (k == 0) {
        cout << "3 2\n1 2\n2 3\n";
        return;
    }
    bool neg = k > 0;
    build({1}, abs(k), neg);
    cout << n << " " << (int) ans.size() << '\n';
    for (int i = 0; i < (int) ans.size(); i++) {
        if (ans[i].first == 2 || ans[i].first == n) ans[i].first = n + 2 - ans[i].first;
        if (ans[i].second == 2 || ans[i].second == n) ans[i].second = n + 2 - ans[i].second;
        cout << ans[i].first << " " << ans[i].second << '\n';
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    int tc = 1;
    //cin >> tc;
    while (tc--) {
        solve();
    }

    return 0;
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Wrong answer.
2 Halted 0 ms 0 KB -