Submission #570627

# Submission time Handle Problem Language Result Execution time Memory
570627 2022-05-30T19:09:16 Z NekoRolly Konstrukcija (COCI20_konstrukcija) C++17
110 / 110
1 ms 352 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+4;

ll k,n,m;
map<ll,vector<int>> anc;
pair<int,int> Ed[N];

int new_1(){ Ed[++m] = {1, ++n};
	return n;
}

int Get(ll k){
	if (anc.count(k)){ ++n;
		for (int x : anc[k]) Ed[++m] = {x, n};
		return n;
	}
	if (k < 0) anc[k] = {Get(-k), Get(-k)}; 
	if (k > 0){
		if (k == 1) anc[k] = {new_1(), new_1()};
		else{ ll x = k/2;
			anc[k] = {Get(-x), Get(-x), Get(-x)};
			if (k%2 == 1) anc[k].push_back(new_1());
		} 
	}
	return Get(k);
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> k; n = 1;

	if (k == 0){
		cout << "3 2\n1 2\n2 3\n"; return 0;
	}

	Get(k);

	cout << n << " " << m << "\n";

	for (int i=1; i<=m; i++)
		cout << Ed[i].first << " " << Ed[i].second << "\n";

    return 0;
}
//576,460,752,303,423,488
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Correct.
2 Correct 0 ms 212 KB Correct.
3 Correct 0 ms 212 KB Correct.
4 Correct 0 ms 212 KB Correct.
5 Correct 1 ms 212 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Correct.
2 Correct 0 ms 212 KB Correct.
3 Correct 0 ms 212 KB Correct.
4 Correct 0 ms 212 KB Correct.
5 Correct 0 ms 212 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Correct.
2 Correct 0 ms 212 KB Correct.
3 Correct 0 ms 212 KB Correct.
4 Correct 0 ms 212 KB Correct.
5 Correct 1 ms 212 KB Correct.
6 Correct 0 ms 212 KB Correct.
7 Correct 0 ms 212 KB Correct.
8 Correct 0 ms 212 KB Correct.
9 Correct 0 ms 212 KB Correct.
10 Correct 0 ms 212 KB Correct.
11 Correct 0 ms 212 KB Correct.
12 Correct 0 ms 212 KB Correct.
13 Correct 1 ms 212 KB Correct.
14 Correct 0 ms 212 KB Correct.
15 Correct 0 ms 212 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Correct.
2 Correct 0 ms 212 KB Correct.
3 Correct 0 ms 212 KB Correct.
4 Correct 0 ms 212 KB Correct.
5 Correct 1 ms 212 KB Correct.
6 Correct 0 ms 212 KB Correct.
7 Correct 0 ms 212 KB Correct.
8 Correct 0 ms 212 KB Correct.
9 Correct 0 ms 212 KB Correct.
10 Correct 0 ms 212 KB Correct.
11 Correct 0 ms 212 KB Correct.
12 Correct 0 ms 212 KB Correct.
13 Correct 1 ms 212 KB Correct.
14 Correct 0 ms 212 KB Correct.
15 Correct 0 ms 212 KB Correct.
16 Correct 1 ms 352 KB Correct.
17 Correct 1 ms 340 KB Correct.
18 Correct 1 ms 340 KB Correct.
19 Correct 1 ms 340 KB Correct.
20 Correct 1 ms 328 KB Correct.
21 Correct 1 ms 340 KB Correct.
22 Correct 1 ms 340 KB Correct.
23 Correct 1 ms 332 KB Correct.
24 Correct 1 ms 340 KB Correct.
25 Correct 1 ms 340 KB Correct.
26 Correct 1 ms 340 KB Correct.
27 Correct 1 ms 336 KB Correct.