2018HDU多校训练一 C -Triangle Partition
Chiaki has 3n3n points p1,p2,…,p3np1,p2,…,p3n. It is guaranteed that no three points are collinear.
Chiaki would like to construct nn disjoint triangles where each vertex comes from the 3n3n points.
Input
There are multiple test cases. The first line of input contains an integer TT, indicating the number of test cases. For each test case:
The first line contains an integer nn (1≤n≤10001≤n≤1000) -- the number of triangle to construct.
Each of the next 3n3n lines contains two integers xixi and yiyi (−109≤xi,yi≤109−109≤xi,yi≤109).
It is guaranteed that the sum of all nn does not exceed 1000010000.
Output
For each test case, output nn lines contain three integers ai,bi,ciai,bi,ci (1≤ai,bi,ci≤3n1≤ai,bi,ci≤3n) each denoting the indices of points the ii-th triangle use. If there are multiple solutions, you can output any of them.
Sample Input
1
1
1 2
2 3
3 5
Sample Output
1 2 3
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
typedef pair<int,int> PII;
const int N=101000;
int T,n,x,y;
pair<PII,int> p[N];
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=0;i<3*n;i++)
{
scanf("%d%d",&x,&y);
p[i]=mp(mp(x,y),i);
}
sort(p,p+3*n);
for(int i=0;i<n;i++)
printf("%d %d %d\n",p[3*i].second+1,p[3*i+1].second+1,p[3*i+2].second+1);
}
return 0;
}
2018HDU多校训练一 C -Triangle Partition的更多相关文章
- 2018HDU多校训练-3-Problem M. Walking Plan
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6331 Walking Plan Problem Description There are n inte ...
- 2018HDU多校训练-3-Problem G. Interstellar Travel
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6325 Interstellar Tra ...
- 2018HDU多校训练-3-Problem F. Grab The Tree
Little Q and Little T are playing a game on a tree. There are n vertices on the tree, labeled by 1,2 ...
- 2018HDU多校训练-3-Problem D. Euler Function
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6322 Problem Description In number theory, Euler's toti ...
- 2018HDU多校训练一 K - Time Zone
Chiaki often participates in international competitive programming contests. The time zone becomes a ...
- 2018HDU多校训练一 D Distinct Values
hiaki has an array of nn positive integers. You are told some facts about the array: for every two e ...
- 2018HDU多校训练一 A - Maximum Multiple
Given an integer nn, Chiaki would like to find three positive integers xx, yy and zzsuch that: n=x+y ...
- HDU 多校对抗赛 C Triangle Partition
Triangle Partition Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Oth ...
- HDU 2018 Multi-University Training Contest 1 Triangle Partition 【YY】
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6300 Triangle Partition Time Limit: 2000/1000 MS (Java ...
随机推荐
- 比较一下inner join(可直接简写为join)和where直接关联
SELECT * FROM A ,B WHERE A.ID = B.ID 是比较常用的2个表关联.之前一直用这个,后来换了家公司发现这家公司的报表大多数都是用inner join,稍微研究了一下.查阅 ...
- [Error]使用了未经检查或不安全的操作...
编译错误注: MethodReflect.java使用了未经检查或不安全的操作.注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译. 解决:在类前面加入下面一句解决 @Suppr ...
- Java代码自动生成,生成前端vue+后端controller、service、dao代码,根据表名自动生成增删改查功能
本项目地址:https://github.com/OceanBBBBbb/ocean-code-generator 项目简介 ocean-code-generator采用(适用): ,并使用m ...
- hdu 2527 Safe Or Unsafe (优先队列实现Huffman)
Safe Or UnsafeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- nyoj 366-D的小L (next_permutation())
366-D的小L 内存限制:64MB 时间限制:4000ms 特判: No 通过数:5 提交数:7 难度:2 题目描述: 一天TC的匡匡找ACM的小L玩三国杀,但是这会小L忙着哩,不想和匡 ...
- ES6入门十二:Module(模块化)
webpack4打包配置babel7转码ES6 Module语法与API的使用 import() Module加载实现原理 Commonjs规范的模块与ES6模块的差异 ES6模块与Nodejs模块相 ...
- 某些机root也不能访问dma-buf
从4.3后,回顾<从surfaceflinger历史变更谈截屏>,只能通过生产消费者队列向surfaceflinger服务申请显示缓冲,这个缓冲就是dma-buf映射的共享内存. bind ...
- vue-cli从2升级到3报错error 404 Not Found: @wry/context@^0.4.0
vue3出来了,想尝尝鲜. 于是按官方的方法卸载2安装3. npm uninstall vue-cli -g npm install -g @vue/cli 但是报错了 error 404 Not F ...
- JavaWeb02-Servlet
Servlet概述 生命周期方法: l void init(ServletConfig):出生之后(1次): l void service(ServletRequest request, Serv ...
- 复习-java集合简记
1.集合概述 ava集合类存放于 java.util 包中,是一个用来存放对象的容器. 集合只能保存对象(实际上也是保存对象的引用变量),Java主要由两个接口派生而出:Collection和Map, ...