Submission #467461

# Submission time Handle Problem Language Result Execution time Memory
467461 2021-08-23T05:07:51 Z two_sides Konstrukcija (COCI20_konstrukcija) C++17
110 / 110
1 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    long long k; cin >> k;
    if (k == 0) {
        cout << "3 2\n1 2\n2 3\n";
        return 0;
    }
    bool neg = k < 0 ? k = -k, true : false;
    vector<int> cur(1, 1), nxt;
    vector<pair<int, int>> edges;
    int n = 1;
    for (int i = 62 - __builtin_clzll(k); i >= 0; i--) {
        for (int j = 1; j <= 3; j++)
            nxt.push_back(++n);
        for (int u : cur)
            for (int v : nxt)
                edges.emplace_back(u, v);
        if (k >> i & 1) {
            nxt.push_back(++n);
            edges.emplace_back(1, n);
        }
        swap(cur, nxt); nxt.clear();
        for (int j = 1; j <= 2; j++)
            nxt.push_back(++n);
        for (int u : cur)
            for (int v : nxt)
                edges.emplace_back(u, v);
        swap(cur, nxt); nxt.clear();
    }
    if (!neg) {
        for (int j = 1; j <= 2; j++)
            nxt.push_back(++n);
        for (int u : cur)
            for (int v : nxt)
                edges.emplace_back(u, v);
        swap(cur, nxt); nxt.clear();
    }
    ++n;
    for (int u : cur)
        edges.emplace_back(u, n);
    cout << n << ' ' << edges.size() << '\n';
    for (auto e : edges)
        cout << e.first << ' ' << e.second << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Correct.
2 Correct 0 ms 204 KB Correct.
3 Correct 1 ms 204 KB Correct.
4 Correct 0 ms 204 KB Correct.
5 Correct 1 ms 204 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Correct.
2 Correct 0 ms 204 KB Correct.
3 Correct 0 ms 204 KB Correct.
4 Correct 1 ms 204 KB Correct.
5 Correct 1 ms 204 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Correct.
2 Correct 0 ms 204 KB Correct.
3 Correct 1 ms 204 KB Correct.
4 Correct 0 ms 204 KB Correct.
5 Correct 1 ms 204 KB Correct.
6 Correct 0 ms 204 KB Correct.
7 Correct 0 ms 204 KB Correct.
8 Correct 0 ms 204 KB Correct.
9 Correct 1 ms 204 KB Correct.
10 Correct 1 ms 204 KB Correct.
11 Correct 0 ms 204 KB Correct.
12 Correct 1 ms 312 KB Correct.
13 Correct 1 ms 204 KB Correct.
14 Correct 0 ms 204 KB Correct.
15 Correct 0 ms 204 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Correct.
2 Correct 0 ms 204 KB Correct.
3 Correct 1 ms 204 KB Correct.
4 Correct 0 ms 204 KB Correct.
5 Correct 1 ms 204 KB Correct.
6 Correct 0 ms 204 KB Correct.
7 Correct 0 ms 204 KB Correct.
8 Correct 0 ms 204 KB Correct.
9 Correct 1 ms 204 KB Correct.
10 Correct 1 ms 204 KB Correct.
11 Correct 0 ms 204 KB Correct.
12 Correct 1 ms 312 KB Correct.
13 Correct 1 ms 204 KB Correct.
14 Correct 0 ms 204 KB Correct.
15 Correct 0 ms 204 KB Correct.
16 Correct 1 ms 332 KB Correct.
17 Correct 1 ms 332 KB Correct.
18 Correct 1 ms 332 KB Correct.
19 Correct 1 ms 332 KB Correct.
20 Correct 1 ms 332 KB Correct.
21 Correct 1 ms 332 KB Correct.
22 Correct 1 ms 332 KB Correct.
23 Correct 1 ms 332 KB Correct.
24 Correct 1 ms 332 KB Correct.
25 Correct 1 ms 332 KB Correct.
26 Correct 1 ms 332 KB Correct.
27 Correct 1 ms 332 KB Correct.