Codeforces Round #378 (Div. 2) D. Kostya the Sculptor map+pair
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.5 respectively.
- 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.
题意:给你n个长方题,每次可以取1个或者两个拼接,求使得内接圆半径最大;输出方案;
思路:map标记;排个序可以减少5次,懒得改了;
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
const int N=2e5+,M=4e6+,inf=1e9+,mod=1e9+;
const ll INF=1e18+;
map<pair<int,int>,pair<int,int> >mp;
int a[];
vector<int>v;
int min(int x,int y,int z)
{
return min(x,min(y,z));
}
int ans;
void update(int a,int b,int c,int i)
{
int minnn=min(a,b,c+mp[make_pair(a,b)].first);
//cout<<minnn<<endl;
if(minnn>ans)
{
ans=minnn;
v.clear();
v.push_back(i);
v.push_back(mp[make_pair(a,b)].second);
}
}
void hh(int a,int b,int c,int i)
{
if(c>mp[make_pair(a,b)].first)
{
mp[make_pair(a,b)]=make_pair(c,i);
}
}
int main()
{
int n;
ans=;
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%d%d%d",&a[],&a[],&a[]);
int minn=min(a[],a[],a[]);
if(minn>ans)
{
ans=minn;
v.clear();
v.push_back(i);
}
update(a[],a[],a[],i);
update(a[],a[],a[],i);
update(a[],a[],a[],i);
update(a[],a[],a[],i);
update(a[],a[],a[],i);
update(a[],a[],a[],i);
hh(a[],a[],a[],i);
hh(a[],a[],a[],i);
hh(a[],a[],a[],i);
hh(a[],a[],a[],i);
hh(a[],a[],a[],i);
hh(a[],a[],a[],i);
}
printf("%d\n",v.size());
for(int i=;i<v.size();i++)
printf("%d ",v[i]);
return ;
}
Codeforces Round #378 (Div. 2) D. Kostya the Sculptor map+pair的更多相关文章
- 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 分组 + 贪心
http://codeforces.com/contest/733/problem/D 给定n个长方体,然后每个长方体都能选择任何一个面,去和其他长方体接在一起,也可以自己一个,要求使得新的长方体的最 ...
- Codeforces Round #486 (Div. 3) C "Equal Sums" (map+pair<>)
传送门 •题意 给k个数列,从中k个数列中找出任意2个数列 i ,j 使得数列i删除第x个数,和数列j删除第y个数的和相等 若存在,输出 i ,x 和 j,y •思路 每个数列之间的联系为数列的和之间 ...
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...
- Codeforces Round #378 (Div. 2) A B C D 施工中
A. Grasshopper And the String time limit per test 1 second memory limit per test 256 megabytes input ...
- Codeforces Round #285 (Div. 2) A, B , C 水, map ,拓扑
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #378 (Div. 2)F - Drivers Dissatisfaction GNU
http://codeforces.com/contest/733/problem/F 题意:给你一些城市和一些路,每条路有不满意程度和每减少一点不满意程度的花费,给出最大花费,要求找出花费小于s的最 ...
- Codeforces Round #378 (Div. 2)
A: 思路: 水题,没啥意思; B: 思路: 暴力,也没啥意思; C: 思路: 思维,可以发现从前往后和为b[i]的分成一块,然后这一块里面如果都相同就没法开始吃,然后再暴力找到那个最大的且能一开始就 ...
- Codeforces Round #378 (Div. 2) C D
在实验室通宵 一边做水题一边准备随时躲起来以免被门卫大爷巡查发现..结果居然没来.. 本来以为可以加几分变个颜色..结果挂了CD...状态有点差...思维不太活跃 沉迷暴力不能自拔 D 给出n个长方体 ...
随机推荐
- 好用的 diskpart 命令,操作磁盘分区,并创建 EFI 引导分区
进入 win8 pe, 或在安装 win8 选择安装磁盘分区时按 shift+F10,都是可能用到 diskpart 去操作的时候. 进入cmd后, diskpart 进入 list disk---- ...
- InnoDB Status Output – Buffer Pool and Spin Rounds
InnoDB has a good source of information about its status which can be requested every time you need ...
- 【python cookbook】【数据结构与算法】19.同时对数据做转换和换算
问题:我们需要调用一个换算函数(例如sum().min().max()),但是首先需对数据做转换或者筛选处理 解决方案:非常优雅的方法---在函数参数中使用生成器表达式 例如: # 计算平方和 num ...
- 161028、Nginx负载均衡实现tomcat集群方案简要小结
重点两部分:一.负载均衡二.tomcat集群 所谓tomcat集群,就是可以向外提供并行服务的多台机器,任何一台服务器宕机,其它服务器可以替代它向外提供服务,而不影响用户访问. Nginx是一个常用的 ...
- Hibernate,JPA注解@OneToMany_Set
用例代码如下: 数据库DDL语句 1,CAT表 create table CAT ( id CHAR) not null, create_time ), update_time ), cat_name ...
- drupal 自定义表单调用autocomplete主标签实现方法
代码如下: <php function module_name_form() { $form = array(); $form['city'] = array( '#title' => t ...
- PHP中Redis替代文件存储Session语句
php默认使用文件存储session,如果并发量大,效率非常低.而Redis对高并发的支持非常好,所以,可以使用redis替代文件存储session. 这里,介绍下php的 session_set_s ...
- PHP面向对象的一些深入理解
1.$this就是这个对象的地址,$this不能在类外部使用.2.构造函数 __construct 和析构函数都没有返回值:一旦一个对象成为垃圾对象(没有任何变量引用的对象,或者=null),析构函数 ...
- 13、mysql/触发器
1. mysql mysql基础 1)mysql存储结构: 数据库 -> 表 -> 数据 sql语句 2)管理数据库: 增加: create database 数据库 default ...
- lua代码优化(转)
暂时转了别人一篇,以后再优化 1.使用局部变量local 这是最基础也是最有用的策略,虽然使用全局变量并不能完全避免,但还是应该尽量避免,取而代之使用局部变量即local.这里的局部变量也包括函数fu ...