Submission #570625

# Submission time Handle Problem Language Result Execution time Memory
570625 2022-05-30T18:53:36 Z NekoRolly Konstrukcija (COCI20_konstrukcija) C++17
30 / 110
1 ms 328 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 << "2 1\n1 2\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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Correct.
2 Correct 1 ms 212 KB Correct.
3 Correct 1 ms 212 KB Correct.
4 Correct 1 ms 212 KB Correct.
5 Correct 1 ms 212 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Correct.
2 Correct 1 ms 212 KB Correct.
3 Correct 1 ms 212 KB Correct.
4 Correct 1 ms 212 KB Correct.
5 Correct 1 ms 212 KB Correct.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Correct.
2 Correct 1 ms 212 KB Correct.
3 Correct 1 ms 212 KB Correct.
4 Correct 1 ms 212 KB Correct.
5 Correct 1 ms 212 KB Correct.
6 Correct 1 ms 328 KB Correct.
7 Correct 1 ms 212 KB Correct.
8 Correct 1 ms 212 KB Correct.
9 Correct 1 ms 212 KB Correct.
10 Correct 1 ms 212 KB Correct.
11 Correct 1 ms 212 KB Correct.
12 Correct 1 ms 212 KB Correct.
13 Correct 1 ms 212 KB Correct.
14 Correct 1 ms 212 KB Correct.
15 Incorrect 1 ms 212 KB Wrong answer.
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Correct.
2 Correct 1 ms 212 KB Correct.
3 Correct 1 ms 212 KB Correct.
4 Correct 1 ms 212 KB Correct.
5 Correct 1 ms 212 KB Correct.
6 Correct 1 ms 328 KB Correct.
7 Correct 1 ms 212 KB Correct.
8 Correct 1 ms 212 KB Correct.
9 Correct 1 ms 212 KB Correct.
10 Correct 1 ms 212 KB Correct.
11 Correct 1 ms 212 KB Correct.
12 Correct 1 ms 212 KB Correct.
13 Correct 1 ms 212 KB Correct.
14 Correct 1 ms 212 KB Correct.
15 Incorrect 1 ms 212 KB Wrong answer.
16 Halted 0 ms 0 KB -