CodeForces - 733D Kostya the Sculptor

D. Kostya the Sculptor
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. Kostya has a friend Zahar who works at a career. Zahar knows about Kostya's idea and wants to present him a rectangular parallelepiped of marble from which he can carve the sphere.

Zahar has n stones which are rectangular parallelepipeds. The edges sizes of the i-th of them are aibi and ci. He can take no more than two stones and present them to Kostya.

If Zahar takes two stones, he should glue them together on one of the faces in order to get a new piece of rectangular parallelepiped of marble. Thus, it is possible to glue a pair of stones together if and only if two faces on which they are glued together match as rectangles. In such gluing it is allowed to rotate and flip the stones in any way.

Help Zahar choose such a present so that Kostya can carve a sphere of the maximum possible volume and present it to Zahar.

Input

The first line contains the integer n (1 ≤ n ≤ 105).

n lines follow, in the i-th of which there are three integers ai, bi and ci (1 ≤ ai, bi, ci ≤ 109) — the lengths of edges of the i-th stone. Note, that two stones may have exactly the same sizes, but they still will be considered two different stones.

Output

In the first line print k (1 ≤ k ≤ 2) the number of stones which Zahar has chosen. In the second line print k distinct integers from 1 to n — the numbers of stones which Zahar needs to choose. Consider that stones are numbered from 1 to n in the order as they are given in the input data.

You can print the stones in arbitrary order. If there are several answers print any of them.

Examples
input
6
5 5 5
3 2 4
1 4 1
2 1 3
3 2 4
3 3 4
output
1
1
input
7
10 7 8
5 10 3
4 2 6
5 5 5
10 2 8
4 2 1
7 7 7
output
2
1 5
 
   
题意: 给你一些长方体,其中如果两个长方体的一个面面积相等,则这两个长方体可以粘起来,但是一个大的长方体最多可以由两个小长方体粘起来吗,当然也可以是一个长方体。让你求这个长方体的内接圆【注意: 是内接圆,一开始以为是外接圆,唉~】的最大半径的长方体的坐标 ,
如果是一个小长方体则输出
1
index1
如果是两个长方体粘起来的则输出
2
index1 index2
思路: 分析一下可以得到内接圆的半径的限制条件就是这个长方体de最短的一条边,最短边越短,半径越小,最短边越大 半径越大。所以要使最短边尽可能的长。
所以如果是两个长方体粘起来的情况,则一定是两个长方体的最长边和次长边组成的那一面粘起来。所以直接对按重要性先以最长边,其次是次长边,最后是最短边排序   所以只需要比较最短边!!!!!!!!!  说了这么多  就是比较最短边,但是要把粘起来的情况考虑进去!!
 
   
代码:
 
   
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#define N 100005

using namespace std;

struct node
{
	int x,y,z,index;
}a[N];

bool cmp(node a,node b)
{
	if(a.x==b.x&&a.y==b.y) return a.z>b.z;
	else if(a.x==b.x) return a.y>b.y;
	else return a.x>b.x;
}

int main()
{
	int n;
	int i,j;
	int x,y,z;
	scanf("%d",&n);
	int maxx=-1;
	int index1=-1,index2=-1;
	for(i=1;i<=n;i++)
	{
		scanf("%d %d %d",&x,&y,&z);
		int sum=x+y+z;
		a[i].x=max(max(x,y),z);
		a[i].z=min(min(x,y),z);
		a[i].y=sum-a[i].x-a[i].z;
		a[i].index=i;
		if(a[i].z>maxx )
		{
			 maxx=a[i].z;
			 index1=i;
		}
	}
	sort(a+1,a+n+1,cmp);
	/*for(i=1;i<=n;i++)
	{
		printf("%d %d %d %d\n",a[i].index,a[i].x,a[i].y,a[i].z);
	}
	*/
	int left=1;
	int right=1;
	while(1)
	{
		if(left==n+1) break;
		right=left;
		while(a[left].x==a[right].x&&a[left].y==a[right].y) right++;
		right--;
		int sum;
		if(left==right)
		{
			sum=min(a[left].x,min(a[left].y,a[left].z));
			if(sum>maxx)
			{
				index1=a[left].index;
				maxx=sum;
				index2=-1;
			}
		}
		else
		{
			sum=min(min(a[left].x,a[left].y),a[left].z+a[left+1].z);
			if(sum>maxx)
			{
				maxx=sum;
				index1=a[left].index;
				index2=a[left+1].index;
			}
		}
		left=right+1;
	}
	if(index2==-1) printf("1\n%d\n",index1);
	else printf("2\n%d %d\n",index1,index2);
	return 0;
}


1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READme.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值