CodeForces

来源:互联网 发布:2016男女对唱新歌网络 编辑:程序博客网 时间:2024/06/10 23:28
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
65 5 53 2 41 4 12 1 33 2 43 3 4
output
11
input
710 7 85 10 34 2 65 5 510 2 84 2 17 7 7
output
21 5
题意: 给你一些长方体,其中如果两个长方体的一个面面积相等,则这两个长方体可以粘起来,但是一个大的长方体最多可以由两个小长方体粘起来吗,当然也可以是一个长方体。让你求这个长方体的内接圆【注意: 是内接圆,一开始以为是外接圆,唉~】的最大半径的长方体的坐标 ,
如果是一个小长方体则输出
1
index1
如果是两个长方体粘起来的则输出
2
index1 index2
思路: 分析一下可以得到内接圆的半径的限制条件就是这个长方体de最短的一条边,最短边越短,半径越小,最短边越大 半径越大。所以要使最短边尽可能的长。
所以如果是两个长方体粘起来的情况,则一定是两个长方体的最长边和次长边组成的那一面粘起来。所以直接对按重要性先以最长边,其次是次长边,最后是最短边排序   所以只需要比较最短边!!!!!!!!!  说了这么多  就是比较最短边,但是要把粘起来的情况考虑进去!!
代码:
#include<stdio.h>#include<string.h>#include<iostream>#include<algorithm>#define N 100005using 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;}