Submission #392129

# Submission time Handle Problem Language Result Execution time Memory
392129 2021-04-20T14:30:14 Z phathnv Konstrukcija (COCI20_konstrukcija) C++11
0 / 110
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int n, neg;
ll k;
vector<int> lastLayer;
vector<pair<int, int>> edges;

void AddLayer(int sz){
    vector<int> nxtLayer;
    for(int i = 1; i <= sz; i++)
        nxtLayer.push_back(++n);
    for(int u : lastLayer)
        for(int v : nxtLayer)
            edges.push_back({u, v});
    lastLayer = nxtLayer;
}

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

    cin >> k;
    if (k == 0){
        cout << "3 2\n";
        cout << "1 2\n";
        cout << "2 3\n";
        return 0;
    }
    if (k < 0){
        neg = 1;
        k *= -1;
    }

    lastLayer = {1};
    int p = 0;
    for(int i = 0; i < 60; i++)
        if ((k >> i) & 1)
            p = i;
    for(int i = p - 1; i >= 0; i--){
        if ((k >> i) & 1){
            lastLayer.push_back(++n);
            edges.push_back({1, n});
        }
        AddLayer(3);
    }
    if (!neg)
        AddLayer(2);
    AddLayer(1);

    cout << n << ' ' << edges.size() << '\n';
    for(auto p : edges)
        cout << p.first << ' ' << p.second << '\n';

    return 0;
}

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