Submission #392111

# Submission time Handle Problem Language Result Execution time Memory
392111 2021-04-20T14:04:54 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, sign, curSign;
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});
    curSign *= -1;
    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;
    } else if (k < 0){
        curSign = -1;
        k = -k;
    } else {
        curSign = 1;
    }

    n = 1, curSign = -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--)
        AddLayer(3 + ((k >> i) & 1));
    if (curSign != sign)
        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 answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer.
2 Halted 0 ms 0 KB -