Submission #846472

# Submission time Handle Problem Language Result Execution time Memory
846472 2023-09-07T15:17:52 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;
 
int N = 1;
vector<pair<int,int>> edges;
vector<int> nodes_now;
void addEdge(int cnt, bool root) {
	vector<int> new_nodes;
	if (root) {
		edges.push_back({1, N+1});
		new_nodes.push_back(N+1);
		N++;
	}
	for (int i = N+1; i <= N+cnt; i++)
		new_nodes.push_back(i);
	N += cnt;
 
	for (auto u : nodes_now) {
		for (auto to : new_nodes)
			edges.push_back({u, to});
	}
	nodes_now = new_nodes;
}
 
void minus1() {
	addEdge(2, false);
}
 
void minus2() {
	addEdge(3, false);
}
 
void minusSm1() {
	addEdge(1, true);
}
 
int main() {
	fast
	ll K;
	cin >> K;
 
	ll now = 0;
	nodes_now.push_back(1); 
	for (int i = 63; i >= 0; i--) {
		if ((1<<i) & K) {
			minusSm1();
			now = - 1 - now;
		}
 
		if (i != 0) {
			minus2();
			now *= -2;
		}
 
		if (now > 0) {
			minus1();
			now = -now;
		}
	}
 
	if (!((now < 0 && K > 0) || (now > 0 && K < 0)))
		minus1();
	addEdge(1, 0);
 
	cout <<	N << " " << edges.size() << "\n";
	for (auto u : edges)
		cout << u.f << " " << u.s << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Wrong answer.
2 Halted 0 ms 0 KB -