Submission #8358090


Source Code Expand

Copy
#include <bits/stdc++.h>
#define MAX 100010
using namespace std;

vector<pair<int, int>> tri;

void getTri(int l, int r)
{
	if (l + 1 == r)
	{
		tri.push_back({l, r});
		return;
	}
	if (l + 3 == r)
	{
		tri.push_back({l, r - 1});
		tri.push_back({l + 1, r});
		return;
	}
	int n = ((r - l + 1) / 2 + 1) / 2;
	for (int i = 0; i < n; i++) tri.push_back({l + i, r - (n - 1) + i});
	int m = (l + r + 1) / 2;
	for (int i = m; i <= r - n; i++) tri.push_back({l + n + i - m, i});
}

int mycmp(const pair<int, int> a, const pair<int, int> b)
{
	return a.first + a.second < b.first + b.second;
}

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N, K;
	cin >> N >> K;
	if (2 * K - 2 > N - 1)
	{
		cout << -1 << endl;
		return 0;
	}
	getTri(K, K + 2 * N - 1);
	sort(tri.begin(), tri.end(), mycmp);
	for (int i = 0; i < N; i++) cout << tri[i].first << " " << tri[i].second << " " << K + 2 * N + i << "\n";
	return 0;
}

Submission Info

Submission Time
Task E - Non-triangular Triplets
User didgogns
Language C++14 (GCC 5.4.1)
Score 700
Code Size 985 Byte
Status
Exec Time 44 ms
Memory 3188 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample01.txt, sample02.txt
All 700 / 700 sample01.txt, sample02.txt, in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
in01.txt 41 ms 2932 KB
in02.txt 43 ms 3060 KB
in03.txt 42 ms 3060 KB
in04.txt 43 ms 3060 KB
in05.txt 40 ms 2932 KB
in06.txt 40 ms 2932 KB
in07.txt 41 ms 3060 KB
in08.txt 40 ms 2932 KB
in09.txt 39 ms 2932 KB
in10.txt 43 ms 3188 KB
in11.txt 39 ms 2932 KB
in12.txt 40 ms 2932 KB
in13.txt 43 ms 3188 KB
in14.txt 38 ms 2804 KB
in15.txt 39 ms 2932 KB
in16.txt 42 ms 3060 KB
in17.txt 43 ms 3188 KB
in18.txt 34 ms 2548 KB
in19.txt 38 ms 2804 KB
in20.txt 43 ms 3060 KB
in21.txt 1 ms 256 KB
in22.txt 1 ms 256 KB
in23.txt 43 ms 3060 KB
in24.txt 1 ms 256 KB
in25.txt 24 ms 1912 KB
in26.txt 22 ms 1656 KB
in27.txt 11 ms 1020 KB
in28.txt 17 ms 1400 KB
in29.txt 1 ms 256 KB
in30.txt 1 ms 256 KB
in31.txt 44 ms 3188 KB
in32.txt 1 ms 256 KB
in33.txt 1 ms 256 KB
in34.txt 1 ms 256 KB
sample01.txt 1 ms 256 KB
sample02.txt 1 ms 256 KB