Submission #478209

# Submission time Handle Problem Language Result Execution time Memory
478209 2021-10-06T13:17:33 Z NachoLibre Konstrukcija (COCI20_konstrukcija) C++17
0 / 110
1 ms 204 KB
#include <bits/stdc++.h>
#define ll long long
#define sz(x) ((int)x.size())
using namespace std;

int n = 1;
vector<int> lr{1};
vector<pair<int, int>> fp;
void add3(int x) {
	fp.push_back({1, ++n});
	fp.push_back({1, ++n});
	fp.push_back({1, ++n});
	for(int i = 1; i < x; ++i) {
		n += 3;
		for(int i = 0; i < 3; ++i) {
			for(int j = 0; j < 3; ++j) {
				fp.push_back({n - 3 - i, n - j});
			}
		}
	}
	lr.push_back(n - 0);
	lr.push_back(n - 1);
	lr.push_back(n - 2);
}
void add1() {
	fp.push_back({1, ++n});
	lr.push_back(n);
}
void sub1() {
	fp.push_back({1, ++n});
	fp.push_back({1, ++n});
	n += 3;
	for(int i = 0; i < 2; ++i) {
		for(int j = 0; j < 3; ++j) {
			fp.push_back({n - 3 - i, n - j});
		}
	}
	lr.push_back(n - 0);
	lr.push_back(n - 1);
	lr.push_back(n - 2);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long x = 3;
	vector<pair<long long, int>> v[2];
	for(int i = 1; i <= 60; ++i) {
		v[x > 0].push_back({x, i});
		x = - x * 2 + 3;
	}
	long long k;
	cin >> k; ++k; k = -k;
	int a = 1;
	if(k < 0) a = 0;
	for(int i = sz(v[a]) - 1; i >= 0; --i) {
		long long x = v[a][i].first;
		int y = v[a][i].second;
		while(abs(x) <= abs(k)) {
			k -= x;
			add3(y);
		}
	}
	while(k) {
		if(k > 0) --k, sub1();
		else ++k, add1();
	}
	++n;
	for(int i = 0; i < sz(lr); ++i) {
		fp.push_back({lr[i], n});
	}
	cout << n << " " << sz(fp) << "\n";
	for(int i = 0; i < sz(fp); ++i) {
		cout << fp[i].first << " " << fp[i].second << "\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Wrong answer.
2 Halted 0 ms 0 KB -