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. 关于jQuery easyUI 添加合计统计行

    首先在onLoadSuccess中添加计算函数:计算方法按各自业务需要,我做了一个判断非数 然后再在gatagrid表格添加行,$('#div').datagrid('appendRow', {... ...

  2. nyoj 276-比较字母大小 (顺序比较, 逆序输出)

    276-比较字母大小 内存限制:64MB 时间限制:3000ms 特判: No 通过数:13 提交数:15 难度:1 题目描述: 任意给出两个英文字母,比较它们的大小,规定26个英文字母A,B,C.. ...

  3. secureCRT安装与激活

    SecureCRT安装及激活方式 百度网盘地址: SecureCRT及激活软件的地址: 1. 安装secureCRT 百度网盘下载,点击scrt814-x64.exe,按照提示安装secureCRT, ...

  4. 命令序列 ; & && ||

    ; 从左到右依次被执行,返回最后一个命令的执行状态 & 该命令将在后台被执行,即在子bash中执行(或ctrl+z,bg, jobs,bg 命令号)(变量$!.$one.$two.$three ...

  5. Tarjan-割点

    割点——tarjan #include <bits/stdc++.h> using namespace std; ; ; int n, m; int ans;//个数 * MAXM], n ...

  6. Android官方提供的支持不同屏幕大小的全部方法(转)

    转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/8830286 原文地址为:http://developer.android.com/ ...

  7. Feature Fusion for Online Mutual Knowledge Distillation (CVPR 2019)

    一.解决问题 如何将特征融合与知识蒸馏结合起来,提高模型性能 二.创新点 支持多子网络分支的在线互学习 子网络可以是相同结构也可以是不同结构 应用特征拼接.depthwise+pointwise,将特 ...

  8. java基础总结(1)--深入理解基本数据类型

    深入理解java数据类型 java是一种强类型语言,这就意味着必须为每一个声明变量声明一种类型.在java中,一共有8种数据类型,其中4种整型,2种浮点类型,1种字符类型和一种表示真值的boolean ...

  9. SpringCloud Alibaba微服务实战一 - 基础环境准备

    Springcloud Aibaba现在这么火,我一直想写个基于Springcloud Alibaba一步一步构建微服务架构的系列博客,终于下定决心从今天开始本系列文章的第一篇 - 基础环境准备. 该 ...

  10. Mybatis一级缓存和二级缓存总结

    1:mybatis一级缓存:级别是session级别的,如果是同一个线程,同一个session,同一个查询条件,则只会查询数据库一次 2:mybatis二级缓存:级别是sessionfactory级别 ...