Submission #392138

#TimeUsernameProblemLanguageResultExecution timeMemory
392138phathnvKonstrukcija (COCI20_konstrukcija)C++11
110 / 110
1 ms332 KiB
#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; } n = 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); if ((k >> i) & 1){ lastLayer.push_back(++n); edges.push_back({1, n}); } AddLayer(2); } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...