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 ...
随机推荐
- 轻松实现C/C++各种常见进制相互转换
其它进制转为十进制 在实现这个需求之前,先简单介绍一个c标准库中的一个函数: long strtol( const char *str, char **str_end, int base); 参数详细 ...
- [spark程序]统计人口平均年龄(HDFS文件)(详细过程)
一.题目描述 (1)请编写Spark应用程序,该程序可以在分布式文件系统HDFS中生成一个数据文件peopleage.txt,数据文件包含若干行(比如1000行,或者100万行等等)记录,每行记录只包 ...
- 在校生如何面向面试地学习Java
最近我在博客园里,看到不少在校的同学在学java,而且,在我最近举办的一次直播活动中,也有不少在校生同学来提问,java该怎么学. 对于那些已经工作的同学,哪怕才工作不久,毕竟也能从项目实践里总结和探 ...
- ubuntu18+uwsgi+nginx部署django项目
更新系统软件源 sudo apt-get update pip3安装 sudo apt install python3-pip 安装virtualenvwrapper pip3 install vir ...
- Docker解决下载镜像速度慢
Docker安装好以后要用Docker pull命令下载镜像,但是会出现下载很慢的现象.Docker默认是国外的源,配置国内镜像仓库. 1.cd /etc/docker/路径下 2.编辑daemon. ...
- 前端 vue单页面应用刷新网页后vuex的state数据丢失的解决方案(转载)
最近接手了一个项目,前端后端都要做,之前一直在做服务端的语言.框架和环境,前端啥都不会啊. 突然需要前端编程,两天速成了JS和VUE框架,可惜还是个半吊子.然后遇到了一个困扰了一整天的问题.一直调试都 ...
- 0MQ讲述多线程魔法
为什么你想过的所有你所知道关于并发的事情,不是完全神经病的(Insane),就是假的(Bogus). 并发的定律,e=mc*c.这里并不是爱因斯坦的质能方程.而是 努力 = 代码规模 * (线程冲突碰 ...
- ansible start canal
- name: Start canal server shell: source /etc/profile && nohup /opt/canal/bin/startup.sh
- Alibaba Nacos 学习(四):Nacos Docker
Alibaba Nacos 学习(一):Nacos介绍与安装 Alibaba Nacos 学习(二):Spring Cloud Nacos Config Alibaba Nacos 学习(三):Spr ...
- PHP提高SESSION响应速度的方法有哪些
1.设置多级目录存储SESSION 默认session的存储目录是1级目录,如果用户量比较大,session文件数量就比较大,我们可以设置目录数为2,使用2级目录可以提交查找和存取速度.不过这种方式对 ...