题意是给3n个点,其中不可能存在任意三点共线的情况,让你在其中建n个三角形,点不能重复使用,三角形不能相互覆盖

做法是给每个点排序,按照先y轴排,再x轴排的顺序,三个三个一组从下往上输出,有人说是凸包,其实没那么麻烦

Problem Description

Chiaki has 3n points p1,p2,…,p3n. It is guaranteed that no three points are collinear.
Chiaki would like to construct n disjoint triangles where each vertex comes from the 3n points.
 
Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤1000) -- the number of triangle to construct.
Each of the next 3n lines contains two integers xi and yi (−109≤xi,yi≤109).
It is guaranteed that the sum of all n does not exceed 10000.
 
Output
For each test case, output n lines contain three integers ai,bi,ci (1≤ai,bi,ci≤3n) each denoting the indices of points the i-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 <cstdio>
#include <algorithm> using namespace std; struct node
{
int n;
int x, y;
}p[];
bool cmp(node a, node b)
{
if (a.y == b.y)
return a.x > b.x;
return a.y < b.y;
} int main()
{
int t, n;
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d", &n);
for (int i = ; i < * n; i++)
{
scanf("%d %d", &p[i].x, &p[i].y);
p[i].n = i + ;
} sort(p, p + ( * n), cmp);
for (int i = ; i <= * n; i++)
{
printf("%d", p[i - ].n);
if (i % == )
printf("\n");
else
printf(" ");
} } return ;
}

HDU6300-2018ACM暑假多校联合训练1003-Triangle Partition的更多相关文章

  1. HDU6333-2018ACM暑假多校联合训练1002-Harvest of Apples-莫队+费马小定理

    题意很简单啦,求S(n,m)的值 通过打表我们可以知道 S(n + 1, m) = S(n, m) * 2 - C(n, m); S(n - 1, m) = (S(n, m) + C(n - 1, m ...

  2. HDU6400-2018ACM暑假多校联合训练1004-Parentheses Matrix-构造

    Parentheses Matrix Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Oth ...

  3. HDU6336-2018ACM暑假多校联合训练4-1005-Problem E. Matrix from Arrays-前缀和

    题意是给了一种矩阵的生成方式 让你求两个左边之间的矩阵里面的数加起来的和(不是求矩阵的值) 没看标程之前硬撸写了160行 用了前缀和以后代码量缩短到原来的1/3 根据规律可以推导出这个矩阵是在不断重复 ...

  4. HDU6342-2018ACM暑假多校联合训练4-1011-Problem K. Expression in Memories

    Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262 ...

  5. HDU6330-2018ACM暑假多校联合训练Problem L. Visual Cube

    就是画个图啦 分三个平面去画orz #include <iostream> #include <cmath> #include <cstring> #include ...

  6. HDU6318-2018ACM暑假多校联合训练2-1010-Swaps and Inversions-树状数组

    本题题意是,给你一个长度为n的序列,使用最少的操作把序列转换为从小到大的顺序,并输出操作数*min(x,y) 实质上是算出该序列中有多少逆序对,有归并排序和树状数组两种算法,由于数据之间的差值有点大, ...

  7. HDU6299-2018ACM暑假多校联合训练1002-Balanced Sequence

    这个题的题意是给你n个字符串,认定()是一种平衡的串,两个以上连续的()()也是一种平衡的串,如果一对括号里面包含一个平衡的串,这个括号也被算在这个平衡的串之内, 如(()(()))是一个长度为8的平 ...

  8. HDU6298-2018ACM暑假多校联合训练1001-Maximum Multiple

    题意大致是给你一个整数n,让你确定是否有三个正整数x,y,z既能被n整除,又能x+y+z=n,并使xyz最大 从中根据规律可以看出,只有被3或被4整除的数才能满足题目要求 被3整除的最大值为n^3/3 ...

  9. HDU6301-2018ACM暑假多校联合训练1004-Distinct Values

    题意是一个长度为n的序列,给你m组区间(l,r),在这个区间里不能填入重复的数字,同时使整个序列字典序最小 同学用的优先队列,标程里使用的是贪心同时使用set维护答案序列 贪心是先采用pre数组来确定 ...

  10. HDU6308-2018ACM暑假多校联合训练1011-Time Zone

    题目大意就是给你UTC-8时区的时间 让你求对应时区的时间 哇 这个题 看似简单,但是一开始怎么都过不了啊 同学用自己写的read过了,后来看了一下各位大佬说改成分钟随便过,就随便过了 Problem ...

随机推荐

  1. LeetCode题解 #155 Min Stack

    写一个栈,支持push pop top getMin 难就难在在要在常量时间内返回最小的元素. 一开始乱想了很多东西,想到了HashMap,treeMap,堆什么的,都被自己一一否决了. 后来想到其实 ...

  2. krpano之字幕添加

    字幕是指介绍语音的字幕,字幕随着语音的播放而滚动,随语音暂停而暂停.字幕添加的前提是用之前的方法添加过介绍语音. 原理: 字幕层在溢出隐藏的父元素中向右滑动,当点击声音控制按钮时,字幕位置被固定,再次 ...

  3. JS播放声音 兼容所有浏览器

    JS播放声音 兼容所有浏览器 <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http ...

  4. 浅谈oracle事务

    所谓事务,他是一个操作序列,这些操作要么都执行,要么都不执行,是一个不可分割的工作单元.通俗解释就是事务是把很多事情当成一件事情来完成,也就是大家都在一条船上,要死一起死,要活一起活. 为什么要引入事 ...

  5. Lambda03 方法引用、类型判断、变量引用

    1 方法引用 1.1 方法引用的好处 方法引用结合 Lambda 可以引用已存在的方法,省略很多编码,而且可读性更强,它可以自动装配参数与返回值. 在编写lambda表达式的时候可以通过方法引用的方式 ...

  6. virsh 查看hypervisor特性

    [root@opennebula var]# virsh -c qemu:///system nodeinfo CPU model: x86_64 CPU(s): CPU frequency: MHz ...

  7. PCL 常用小知识

    时间计算 pcl中计算程序运行时间有很多函数,其中利用控制台的时间计算 首先必须包含头文件 #include <pcl/console/time.h> #include <pcl/c ...

  8. JMS-消息中间件的应用02-安装ActiveMQ-来自慕课学习-新手学习

    What is ActiveMQ?       -----突然好想打英文,好奇怪 请看来自官网的介绍: Apache ActiveMQ ™ is the most popular and powerf ...

  9. 过渡函数transition-timing-function

  10. 现代C++学习笔记之二入门篇2,数据转换

    static_cast:    这种强制转换只会在编译时检查. 如果编译器检测到您尝试强制转换完全不兼容的类型,则static_cast会返回错误. 您还可以使用它在基类指针和派生类指针之间强制转换, ...