传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6300

Triangle Partition

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)
Total Submission(s): 2964    Accepted Submission(s): 1474
Special Judge

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
 
Source
 

题意概括:

给出 3*N 个点的坐标(保证点不共线);

用这 3*N 个点构造出 N 个不相交的三角形;

每一行输出一个三角形的坐标编号。

解题思路:
因为点都不共线,所以按横坐标排个序,三个三个点构造的三角形不相交。

AC code:

 #include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define INF 0x3f3f3f3f
#define LL long long
using namespace std;
const int MAXN = 3e3+; struct data
{
int x, y;
int no;
}node[MAXN]; bool cmp(data a, data b)
{
return a.x < b.x;
} int main()
{
int N;
int T_case;
while(~scanf("%d", &T_case)){
while(T_case--){
scanf("%d", &N);
int maxx = *N;
for(int i = ; i < maxx; i++){
scanf("%d %d", &node[i].x, &node[i].y);
node[i].no = i+;
}
sort(node, node+maxx, cmp); for(int i = ; i+ < maxx; i+=){
printf("%d %d %d\n", node[i].no, node[i+].no, node[i+].no);
}
}
}
return ;
}

HDU 2018 Multi-University Training Contest 1 Triangle Partition 【YY】的更多相关文章

  1. hdu 6216 A Cubic number and A Cubic Number【数学题】

    hdu 6216 A Cubic number and A Cubic Number[数学] 题意:判断一个素数是否是两个立方数之差,就是验差分.. 题解:只有相邻两立方数之差才可能,,因为x^3-y ...

  2. 2018 Multi-University Training Contest 4 Problem L. Graph Theory Homework 【YY】

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6343 Problem L. Graph Theory Homework Time Limit: 2000 ...

  3. 2018 Multi-University Training Contest 1 Distinct Values 【贪心 + set】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6301 Distinct Values Time Limit: 4000/2000 MS (Java/Ot ...

  4. hdu 4864 Task---2014 Multi-University Training Contest 1

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4864 Task Time Limit: 4000/2000 MS (Java/Others)    M ...

  5. hdu 4946 2014 Multi-University Training Contest 8

    Area of Mushroom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  6. hdu 4937 2014 Multi-University Training Contest 7 1003

    Lucky Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) T ...

  7. hdu 4941 2014 Multi-University Training Contest 7 1007

    Magical Forest Time Limit: 24000/12000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Other ...

  8. hdu 4939 2014 Multi-University Training Contest 7 1005

    Stupid Tower Defense Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

  9. hdu 5755 2016 Multi-University Training Contest 3 Gambler Bo 高斯消元模3同余方程

    http://acm.hdu.edu.cn/showproblem.php?pid=5755 题意:一个N*M的矩阵,改变一个格子,本身+2,四周+1.同时mod 3;问操作多少次,矩阵变为全0.输出 ...

随机推荐

  1. AngularJS中的动画实现

    AngularJS 动画 AngularJS 提供了动画效果,可以配合 CSS 使用. AngularJS 使用动画需要引入 angular-animate.min.js 库. <script ...

  2. .Net程序员玩转Android系列之二~Android Framework概要(1)

    从windows操作系统说起 人们总是喜欢从将陌生的事物和自己所了解的东西关联起来,以加深对未知事物的了解,这一讲我们从windows操作系统说起,逐步引领带大家走入android的世界.写任何程序都 ...

  3. 使用OpenSSL(Windows x64版)将pem格式证书转换为p12格式

    今天同事遇到一个问题,他获得的证书只有pem格式,而服务器要求提交p12格式,一时搞不定,来找我帮忙. 我之前也从未接触过证书类型的转换,所以上网大致搜索了一下,又亲自动手试了试,现将有关心得经验记录 ...

  4. Python基础学习总结(九)

    11测试代码 1.编写函数和类时,还可以编写测试函数,通过测试可以确定代码面对各种输入都能正常工作.在程序中添加新代码时,也可以对其进行测试,确定他们不会破坏程序的既有程序.要经常测试模块. 2.通过 ...

  5. python文件修改 核心5步,函数实现修改任意文件内容

    文件修改 核心5步1.以读的模式打开原文件,产生句柄f12.以写的模式打开一个新文件,产生句柄f23.读取原文件的内容并将原文件需要替换的内容修改写入到新文件4.删除原文件5.把新文件重名了成原文件 ...

  6. Safari无痕模式下,storage被禁用问题

    前言 Safari开启无痕模式后,localStorage和sessionStorage为空,对其进行set操作也会报错,也就是说这种情况下,storage是被禁止使用了.接下来说一下解决方法. 解决 ...

  7. 深入理解jQuery插件开发总结(三)

    容器:一个即时执行函数 根本上来说,每个插件的代码是被包含在一个即时执行的函数当中,如下: (function(arg1, arg2) { // 代码 })(arg1, arg2); 即时执行函数,顾 ...

  8. python----openpyxl模块

    openpyxl 模块 1.openpyxl的写 from openpyxl import Workbook wb = Workbook() # 方式一: 默认创建sheet在最后 wb1 = wb. ...

  9. perf4j 监控请求 + traceId区分日志

    1. 场景 从request进入Controller到出去的时间, 可以统计接口访问的一些数据,如:平均处理时间.最大处理时间 2. 代码 2.1 mvc-servlet 定义切面和拦截器 <? ...

  10. 视差滚动-background-attachement

    之前项目中没有涉及到视觉滚动的网站,但是毕竟是一种常用的网站类别,不得不了解.实现方法很简单,做一下简单的分析... 概述:滚动视差是指多层背景以不同的速度移动,形成立体的运动效果,来带非常出色的视觉 ...