暴力の構造

トレーニング2 - Dのタイトル

千秋は3n3nポイントP1、P2、...、p3np1、P2、...、P3Nを持っています。何の3点が同一直線上にないことが保証されています。

千秋は、nnは互いに素の三角形の各頂点が3n3nポイントどこから来るのかを構築したいと思います。

入力

複数のテストケースがあります。入力の最初の行は、テストケースの数を示す整数TTを含有します。各テストケースの場合:

コンストラクトに三角形の数 - 最初の行は整数NN(1≤n≤10001≤n≤1000)を含みます。

次3n3nラインの各々は、2つの整数を含む西渓とYiyiの(-109≤xi、yi≤109-109≤xi、yi≤109)。

すべてのNNの合計が十億万を超えていないことが保証されています。

出力

各テストケースのために、ラインNNの出力は三つの整数AI、BI、ciai、BI、CI(1≤ai、BI、ci≤3n1≤ai、BI、ci≤3n)を含有する各点の指標をII番目の三角形を表します使用する。複数の解決策がある場合は、出力は、任意のそれらのことができます。

サンプル入力

1
1
1 2
2 3
3 5

サンプル出力

1 2 3


#pragma warning (disable:4996)
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cstdio>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#define inf 0X3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 3e3 + 5;

struct Node
{
	int x;
	int y;
	int num;
	Node(int xx, int yy, int n)
	{
		x = xx;
		y = yy;
		num = n;
	}
	friend bool operator<(Node a, Node b)
	{
		if (a.x == b.x)
			return a.y < b.y;
		return a.x < b.x;
	}
};
vector<Node> v;

int main()
{
	int T;
	scanf("%d", &T);
	while (T--)
	{
		int n;
		scanf("%d", &n);
		for (int i = 1; i <= 3 * n; i++)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			v.push_back(Node(a, b, i));
		}
		sort(v.begin(), v.end());
		int i = 1, j = 2, k = 3;
		for (int i = 0; i < 3 * n; i += 3)
		{
			for (int j = 0; j < 3; j++)
				printf("%d ", v[i + j].num);
			printf("\n");
		}
		while (v.size())
			v.pop_back();
	}
}

アイデア:
シンプルな出力を注文した後に暴力を判断することはできません。

公開された28元の記事 ウォンの賞賛0 ビュー331

おすすめ

転載: blog.csdn.net/xukeke12138/article/details/104642301