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的更多相关文章

  1. 2018HDU多校训练-3-Problem M. Walking Plan

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6331 Walking Plan  Problem Description There are n inte ...

  2. 2018HDU多校训练-3-Problem G. Interstellar Travel

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6325                                   Interstellar Tra ...

  3. 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 ...

  4. 2018HDU多校训练-3-Problem D. Euler Function

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6322 Problem Description In number theory, Euler's toti ...

  5. 2018HDU多校训练一 K - Time Zone

    Chiaki often participates in international competitive programming contests. The time zone becomes a ...

  6. 2018HDU多校训练一 D Distinct Values

    hiaki has an array of nn positive integers. You are told some facts about the array: for every two e ...

  7. 2018HDU多校训练一 A - Maximum Multiple

    Given an integer nn, Chiaki would like to find three positive integers xx, yy and zzsuch that: n=x+y ...

  8. HDU 多校对抗赛 C Triangle Partition

    Triangle Partition Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Oth ...

  9. 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 ...

随机推荐

  1. 利用爬虫爬取LOL官网上皮肤图片

    今天在浏览网页时,看到一篇很有意思的文章,关于网络爬虫的.该文章是讲述如何利用request爬取英雄联盟官网皮肤图片.看过文章后觉得挺有用的,把代码拿过来运行了一下,果真爬取成功.下面给大家分享一下代 ...

  2. 【Linux】Debian 下安装 Apache,MySQL,PHP

    首先,对你的源进行更新: $ sudo apt-get update 第一步--安装 Apache Apache 是一个开源软件,它目前运行在全球超过 50% 的服务器上,是 LAMP(Linux,A ...

  3. python:0

    if __name__ == '__main__': r = Rectangle() 79 def __str__(self): 80 return "address:(%d, %d)&qu ...

  4. Hook原理--逆向开发

    今天我们将继续讲解逆向开发工程另一个重要内容--Hook原理讲解.Hook,可以中文译为“挂钩”或者“钩子”,逆向开发中改变程序运行的一种技术.按照如下过程进行讲解 Hook概述 Hook技术方式 f ...

  5. PHP 的面向对象 与 类

    面向对象 == OO 学习面向对象 == XXOO;[学习使我快乐!] <!--附一个demo类的实例化--> http://note.youdao.com/noteshare?id=38 ...

  6. uniapp打包Android APP

    1.uniAPP 将项目打包成,打包成功后格式如下 2.下载相关工具 Android studio(打包成app的工具) 和Hbuilder官方SDK,安装解压响应工具 3. 用 Android st ...

  7. 从零开始在ubuntu上配置深度学习开发环境

    从零开始在ubuntu上配置深度学习开发环境 昨天一不小心把原来配置好的台式机的开发环境破坏了,调了半天没有调回来,索性就重装一次ubuntu系统.这篇文章主要记录一个简单的.‘傻瓜式’教程. 一.U ...

  8. 2019/12/1 智能硬件实验室(ROS方向)

    浅谈安装ubuntu与ros感想 ubuntu 以前看电脑软件安装管家上的教程尝试在另一台电脑上安装ubuntu(虚拟机上),但是后面遇到了无法解决的问题,放弃了.这次因为选的ros方向,所以昨天在学 ...

  9. spring奇怪异常记录(会逐渐记录)

    1 严重: Context initialization failedorg.springframework.beans.factory.BeanCreationException: Error cr ...

  10. vue-socket.io使用教程与踩坑记录

    全手打原创,转载请标明出处:https://www.cnblogs.com/dreamsqin/p/12018866.html,多谢,=.=~ (如果对你有帮助的话请帮我点个赞啦) 请先允许我狠狠吐个 ...