# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234297 | 2020-05-23T20:49:46 Z | doowey | Konstrukcija (COCI20_konstrukcija) | C++14 | 5 ms | 384 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int main(){ fastIO; ll k; cin >> k; if(k == 0){ cout << "3 2\n"<< "1 2\n2 3\n"; return 0; } if(k == 1){ cout << "1 0\n"; return 0; } ll go = abs(k); vector<int> di; di.push_back(1); vector<int> tt; int sig = 0; ll cur = -1; for(int i = 0 ; i <= 60 ; i ++ ){ if((go&(1ll<<i))) sig=i; } for(int i = sig; i >= 0 ; i -- ){ if(i < sig && (go&(1ll<<i))){ if(cur < 0){ di.push_back(2); cur *= -1ll; } tt.push_back(di.size()); cur ++ ; } if(i > 0){ di.push_back(3); cur *= -2ll; } } if(cur != k){ di.push_back(2); cur *= -1; } di.push_back(1); int nn = tt.size(); for(auto x : di) nn += x; int m = di.size(); vector<int> p[m]; p[m-1].push_back(nn); int c = 1; for(int i = 0 ; i + 1 < m ; i ++ ){ for(int x = 0; x < di[i]; x ++ ){ p[i].push_back(c); c++; } } vector<pii> sol; for(int i = 0 ; i < tt.size(); i ++ ){ sol.push_back(mp(1, c)); sol.push_back(mp(c, p[tt[i]][0])); c ++ ; } for(int i = 0 ; i + 1 < m; i ++ ){ for(auto x : p[i]){ for(auto y : p[i + 1]){ sol.push_back(mp(x,y)); } } } cout << nn << " " << sol.size() << "\n"; for(auto x : sol) cout << x.fi << " " << x.se << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 384 KB | Wrong answer. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 384 KB | Wrong answer. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 384 KB | Wrong answer. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 384 KB | Wrong answer. |
2 | Halted | 0 ms | 0 KB | - |