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 AC
Exec Time 44 ms
Memory 3188 KB

Judge Result

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