# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
234297 | doowey | Konstrukcija (COCI20_konstrukcija) | C++14 | 5 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |