Submission #467461

#TimeUsernameProblemLanguageResultExecution timeMemory
467461two_sidesKonstrukcija (COCI20_konstrukcija)C++17
110 / 110
1 ms332 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...