답안 #846507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
846507 2023-09-07T16:46:45 Z serifefedartar Konstrukcija (COCI20_konstrukcija) C++17
0 / 110
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 998244353;
const ll LOGN = 20;
const ll MAXN = 3e5 + 5;

ll now = 1;
int N = 1;
vector<int> curr;
vector<pair<int,int>> edges;

void addEdge(int cnt) {
	vector<int> new_nodes;
	for (int i = N+1; i <= N+cnt; i++)
		new_nodes.push_back(i);
	N += cnt;

	for (auto from : curr) {
		for (auto to : new_nodes)
			edges.push_back({from, to});
	}
	curr = new_nodes;
}

void addNode() {
	N++;
	edges.push_back({1, N});
	curr.push_back(N);
	now--;
}

int main() {
	fast
	ll K;
	cin >> K;

	curr.push_back(1);
	for (ll i = 60; i >= 0; i--) {
		if ((1<<i) & K) {
			addEdge(2);
			addNode();
			now = -1*abs(now) - 1;
			addEdge(3);
			now = 2*abs(now);
		} else {
			addEdge(3);
			addEdge(2);
			now = abs(now) * 2;
		}
	}

	if (now == -K)
		addEdge(2);
	cout << "K= " << K << "\n"; 

	cout << N << " " << edges.size() << "\n";
	for (auto u : edges)
		cout << u.f << " " << u.s << "\n"; 
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Expected integer, but "K=" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Expected integer, but "K=" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Expected integer, but "K=" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Expected integer, but "K=" found
2 Halted 0 ms 0 KB -