# Codeforces 733D Kostya The sculptor

Source: Internet
Author: User
Tags min time limit

D. Kostya The sculptor time limit per test 3 seconds memory limit per test megabytes input standard input output stand ARD output

Kostya is a genial sculptor, he had a 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 th E sphere.

Zahar has n stones which is rectangular parallelepipeds. The edges sizes of the i-th of them are AI, bi and CI. He can take no more than, stones and present them to Kostya.

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

Help Zahar choose such a present so, 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 is three integers ai, bi and CI (1≤ai, Bi, ci≤109)-the lengths of edges of the i-th stone. Note, that's stones may has exactly the same sizes, but they still would be considered, and different stones. Output

The first line print K (1≤k≤2) The number of stones which Zahar have chosen. The second line print k distinct integers from 1 to n-the numbers of stones which Zahar needs to choose. Consider that stones is numbered from 1 to N in the order as they is given in the input data.

You can print the stones in arbitrary order. If There is 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
7 8
5 3 4 2
6
5 5 5
2 8
4 2 1
7 7 7
Output
2
1 5
Note

In the first example we can connect the pairs of stones:2 and 4, the size of the parallelepiped: 3x2 X5, the radius of the inscribed sphere 1 2&NBSP;AND&NBSP;5, the size of the parallelepiped: 3x2x8 or& nbsp;6x2x4 or 3x4x4, the radius of the inscribed sphere 1, OR&NBSP;1, or 1.5respectively. 2 and 6, the size of the parallelepiped: 3x5x4, the radius of the inscribed sphere 1.5 4 and& Nbsp;5, the size of the parallelepiped: 3x2x5, the radius of the inscribed sphere 1 5&NBSP;AND&NBSP;6, the S Ize of the parallelepiped: 3x4x5, the radius of the inscribed sphere 1.5

Or take only one stone:1 the size of the parallelepiped:5x5x5, the radius of the inscribed sphere 2.5 2 the size of The parallelepiped:3x2x4, the radius of the inscribed Sphere 1 3 The size of the parallelepiped:1x4x1, the Radiu s of the inscribed sphere 0.5 4 the size of the parallelepiped:2x1x3, the radius of the inscribed sphere 0.5 5 The SI Ze of the parallelepiped:3x2x4, the radius of the inscribed sphere 1 6 The size of the parallelepiped:3x3x4, the Radius of the inscribed sphere 1.5

It's most profitable to take only the first stone.

Test instructions: Give the N box, you can splice two at least one face the same box, you can choose not to splice, ask how to choose the box can be the largest inner-cutting sphere volume.

Problem: Cry blind Ah, the title is wrong, thought can any splicing two cuboid, think for several days also didn't think out how N*log (n) do. Who knows there must be one side of the same to splice. Then it is obvious that the shortest side of the stitching divided by 2 is the radius of the inner tangent sphere. Of course, you can choose not to splice. Water problem, casually engaged in the O (N*log (n)). Eye Blind,/(ㄒoㄒ)/~~

Use STL to write a write, proficiency in the usage, the code is as follows:

#include <iostream>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int a[4];
map< Pair<int, int>, int> temp;
map< Pair<int, Int>, int> ID;
int cnt[2];
int main ()
{
int n, I, K;
while (cin>>n) {
temp.clear ();
Id.clear ();
int sum=0;
for (i = 1; I <= n; ++i) {
cin>>a[0]>>a[1]>>a[2];
Sort (A, a+3);
if (a[0]>sum) {
sum = a[0];
k = 1;  Cnt[0] = i;
}
if (Sum < min (Temp[make_pair (a[1],a[2])] + a[0], a[1]) {
sum = min (Temp[make_pair (a[1],a[2])] + a[0], a[1]);
K =2;
Cnt[0] = Id[make_pair (a[1],a[2]);
CNT[1] = i;
}
if (A[0] > Temp[make_pair (a[1],a[2])) {
Temp[make_pair (a[1],a[2])] = a[0];
Id[make_pair (a[1],a[2])] = i;
}
}
cout<<k<<endl;
if (k==1)
cout<<cnt[0]<<endl;
else
cout<<cnt[0]<< "" <<cnt[1]<<endl;
}
return 0;

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.