제출 #845590

#제출 시각아이디문제언어결과실행 시간메모리
845590vjudge1Konstrukcija (COCI20_konstrukcija)C++17
0 / 110
1 ms348 KiB
#include <bits/stdc++.h> #define pb push_back #define int int64_t using namespace std; constexpr static int MXLOG = 61; int32_t main() { int k; cin >> k; vector<int> v; vector<array<int, 2>> e; int nxt = 1; for (int i = 1; i <= 4; i++) e.pb({0, nxt++}); v.pb(nxt-1); for (int i = 1; i < MXLOG; i++) { for (int j = 0; j < 4; j++) for (int l = 2; l <= 4; l++) e.pb({nxt-l, nxt+j}); nxt+=3; v.pb(nxt++); } for (int i = 0; i < 2; i++) { e.pb({nxt-1, nxt}); nxt++; } while (k != 0) { cout << k << "\n"; int i = 63 - __builtin_clzll(abs(k)); int s = -1; if (i&1) s = 1; if (s == (abs(k) / k)) { k -= (1<<i) * s; e.pb({v[i], nxt-1}); } else { k += (1<<(i+1)) * s; e.pb({v[i+1], nxt-1}); } } nxt++; cout << nxt << " " << e.size() << "\n"; for (auto [a, b] : e) cout << (a+1) << " " << (b+1) << "\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...