CF733D Kostya the Sculptor[贪心 排序]
3 seconds
256 megabytes
standard input
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 ai, bi 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.
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.
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.
6
5 5 5
3 2 4
1 4 1
2 1 3
3 2 4
3 3 4
1
1
7
10 7 8
5 10 3
4 2 6
5 5 5
10 2 8
4 2 1
7 7 7
2
1 5
In the first example we can connect the pairs of stones:
- 2 and 4, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1
- 2 and 5, the size of the parallelepiped: 3 × 2 × 8 or 6 × 2 × 4 or 3 × 4 × 4, the radius of the inscribed sphere 1, or 1, or 1.5respectively.
- 2 and 6, the size of the parallelepiped: 3 × 5 × 4, the radius of the inscribed sphere 1.5
- 4 and 5, the size of the parallelepiped: 3 × 2 × 5, the radius of the inscribed sphere 1
- 5 and 6, the size of the parallelepiped: 3 × 4 × 5, the radius of the inscribed sphere 1.5
Or take only one stone:
- 1 the size of the parallelepiped: 5 × 5 × 5, the radius of the inscribed sphere 2.5
- 2 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1
- 3 the size of the parallelepiped: 1 × 4 × 1, the radius of the inscribed sphere 0.5
- 4 the size of the parallelepiped: 2 × 1 × 3, the radius of the inscribed sphere 0.5
- 5 the size of the parallelepiped: 3 × 2 × 4, the radius of the inscribed sphere 1
- 6 the size of the parallelepiped: 3 × 3 × 4, the radius of the inscribed sphere 1.5
It is most profitable to take only the first stone.
题意:一堆矩形平行六面体(雾
一堆长方体,可以选一个也可以选两个粘起来,求最大的球选哪个
最近数学正好在学立体几何................
园半径是min(a,b,c)/2,让最小边最大就好了
两个粘起来,一定是把最短边粘起来了,否则没有影响啊
所以每个长方体x最长边y次长边z最短边,然后按x,y,z优先级排序,看看相邻两个能不能粘起来行了
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1e5+,INF=1e9+;
inline int read(){
char c=getchar();int x=,f=;
while(c<''||c>''){if(c=='-')f=-;c=getchar();}
while(c>=''&&c<=''){x=x*+c-'';c=getchar();}
return x*f;
} int n,t[],ans1,p1,ans2,p2;
struct rec{
int id,x,y,z;
bool operator <(const rec &r)const{
if(x==r.x){
if(y==r.y) return z>r.z;
else return y>r.y;
}else return x>r.x;
}
}a[N];
int main(){
n=read();
for(int i=;i<=n;i++){
t[]=read();t[]=read();t[]=read();
sort(t+,t+);
a[i].x=t[],a[i].y=t[],a[i].z=t[]; a[i].id=i;
if(a[i].z>ans1) ans1=a[i].z,p1=i;
} sort(a+,a++n);
for(int i=;i<=n;i++){
if(a[i].x==a[i+].x&&a[i].y==a[i+].y){
int t=min(a[i].y,a[i].z+a[i+].z);
if(t>ans2) ans2=t,p2=i;
}
}
if(ans1>ans2) printf("1\n%d",p1);
else printf("2\n%d %d",a[p2].id,a[p2+].id);
}
CF733D Kostya the Sculptor[贪心 排序]的更多相关文章
- [CF733D]Kostya the Sculptor(贪心)
题目链接:http://codeforces.com/contest/733/problem/D 题意:给n个长方体,允许最多两个拼在一起,拼接的面必须长宽相等.问想获得最大的内切圆的长方体序号是多少 ...
- codeforces 733D Kostya the Sculptor(贪心)
Kostya is a genial sculptor, he has an idea: to carve a marble sculpture in the shape of a sphere. K ...
- Codeforces378 D Kostya the Sculptor(贪心)(逻辑)
Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Kostya the Sculptor
Kostya the Sculptor 题目链接:http://codeforces.com/problemset/problem/733/D 贪心 以次小边为第一关键字,最大边为第二关键字,最小边为 ...
- Codeforces Round #378 (Div. 2) D - Kostya the Sculptor
Kostya the Sculptor 这次cf打的又是心累啊,果然我太菜,真的该认真学习,不要随便的浪费时间啦 [题目链接]Kostya the Sculptor &题意: 给你n个长方体, ...
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor map+pair
D. Kostya the Sculptor time limit per test 3 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor 分组 + 贪心
http://codeforces.com/contest/733/problem/D 给定n个长方体,然后每个长方体都能选择任何一个面,去和其他长方体接在一起,也可以自己一个,要求使得新的长方体的最 ...
- Kostya the Sculptor(贪心
这题本来 想二分.想了很久很久,解决不了排序和二分的冲突. 用贪心吧.. 题意: 给你n个长方形,让你找出2个或1个长方体,使得他们拼接成的长方体的内接球半径最大(这是要求最短边越大越好)( ...
- codeforces733D. Kostya the Sculptor 偏序cmp排序,数据结构hash,代码简化
对于n==100.1,1,2或者1,2,2大量重复的形状相同的数据,cmp函数最后一项如果表达式带等于,整个程序就会崩溃 还没有仔细分析std::sort的调用过程,所以这里不是很懂..,mark以后 ...
随机推荐
- [WCF编程]12.事务:事务传播
一.事务传播概述 WCF可以跨越服务边界传递事务.这可以让服务参与到客户端事务里,客户端还可以在同一个事务里调用多个服务.客户端本身不一定是WCF服务.客户端事务是否传播到服务端可以通过绑定和操作契约 ...
- nodejs定义函数的方法
test_163:/home/exenode/part3/module_exports # more calc.js module.exports = { sum:function() { var r ...
- java使用正则从爬虫爬的txt文档中提取QQ邮箱
我的需求是从一堆文档中提取出qq邮箱,写了这篇帖子,希望能帮助和我有一样需求的人,谢谢!...... import java.io.BufferedReader; import java.io.Fil ...
- 仿饿了点餐界面2个ListView联动
如图是效果图 是仿饿了的点餐界面 1.点击左侧的ListView,通过在在适配器中设置Item来改变颜色,再通过notifyDataSetInvalidated来刷新并用lv_home.setSele ...
- 对hashmap,hashset,hashtable的理解
1.首先先理一下java的集合关系,Collection和Map接口是所有集合接口的根结点,其他集合都直接或者间接的实现了他们中的一个:collection下有:list(元素可重复)和set(不可重 ...
- 能力素质模型咨询工具(Part 2)
核心能力素质模型数据库 1. 工作态度 通用 (1)热爱本职工作,对工作充满信心 (2)在没有明确的规定或领导指示的情况下,能够积极主动地承担职责范围内的各项工作,并能够积极地配合其他同事/部门工作 ...
- Raneto Docs(开源的知识库建站程序)
1.Raneto Docs简单说明 a Raneto是一个基于Markdown的开源的node.js知识库平台,它使用Markdown文件来存储知识库,Raneto我们也可以将其称之为"静态 ...
- 详解JavaScript中的this
JavaScript中的this总是让人迷惑,应该是js众所周知的坑之一. 个人也觉得js中的this不是一个好的设计,由于this晚绑定的特性,它可以是全局对象,当前对象,或者…有人甚至因为坑大而不 ...
- K近邻模型(k-NN)
原理 K最近邻(k-Nearest Neighbor,KNN)分类算法,是一个理论上比较成熟的方法,也是最简单的机器学习算法之一.该方法的思路是:如果一个样本在特征空间中的k个最相似(即特征空间中最邻 ...
- Day Tips:关于搜索小问题
1.如果想重启SPSearchHostController请确保没有服务在运行,如果有爬网运行可能会导致重启失败,使之处于stoping状态,不过遇到这个状态也不要紧使用 taskkill /f /f ...