codeforce733D Kostya the Sculptor

本文介绍了一种算法,用于从多个平行六面体中选择两个组成新的平行六面体,以便能够切出最大的球体。该算法使用了map来存储边长信息,并通过比较不同组合确定最优解。

题意

从n个平行六面体中最多选出两个构成一个新的平行六面体,当新的六面体的能切出最大的球体时,应选哪几个平行六面体。
##思路
用map存储两条边对应的最大的第三边的边长和index,把一个平行六面体构成的看成,和一个“空”的组合。对于每个长宽高,三种情况都比较一下,就好了。
##代码

/* ********************************
Author			: danmu
Created Time	: 2016年11月04日 星期五 17时00分35秒
File Name		: d.cpp
******************************** */

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <string>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

#define rep(i,x,y) for(int i=x;i<=y;++i)
#define _rep(i,x,y) for(int i=x;i>=y;--i)
#define CL(S,x) memset(S,x,sizeof(S))
#define CP (S1,S2) memcpy(S1,S2,sizeof(S2))
#define ALL(x,S) for(x=S.begin();x!=S.end();++x)
#define ULL unsigned long long
#define PI 3.1415926535
#define INF 0x3f3f3f3f
#define LL long long

const int maxn = 1e6;
const int mod = 1e9 + 7;
const double eps = 1e-8;

using namespace std;
map<pair<int,int>,pair<int,int> > r;
int minn(int x,int y,int z){
	if(x<y&&x<z) return x;
	if(y<z) return y;
	return z;
}
int main(){
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n,maxx=0,ans1=0,ans2=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		if(a>b) swap(a,b);
		if(a>c) swap(a,c);
		if(b>c) swap(b,c);
		pair<int,int> tmp1,tmp2,tmp3;
		tmp1=make_pair(a,b);
		if(minn(a,b,c+r[tmp1].first)>maxx){
			maxx=minn(a,b,c+r[tmp1].first);
			ans1=i,ans2=r[tmp1].second;
		}
		tmp2=make_pair(a,c);
		if(minn(a,c,b+r[tmp2].first)>maxx){
			maxx=minn(a,c,b+r[tmp2].first);
			ans1=i,ans2=r[tmp2].second;
		}
		tmp3=make_pair(b,c);
		if(minn(b,c,a+r[tmp3].first)>maxx){
			maxx=minn(b,c,a+r[tmp3].first);
			ans1=i,ans2=r[tmp3].second;
		}
		if(r[tmp1].first<c) r[tmp1]=make_pair(c,i);
		if(r[tmp2].first<b) r[tmp2]=make_pair(b,i);
		if(r[tmp3].first<a) r[tmp3]=make_pair(a,i);
	}	
	printf("%d\n",ans2?2:1);
	printf("%d",ans1);
	if(ans2) printf(" %d",ans2);
	puts("");
	return 0;
}
### Codeforces Problem or Contest 998 Information For the specific details on Codeforces problem or contest numbered 998, direct references were not provided within the available citations. However, based on similar structures observed in other contests such as those described where configurations often include constraints like `n` representing numbers of elements with defined ranges[^1], it can be inferred that contest or problem 998 would follow a comparable format. Typically, each Codeforces contest includes several problems labeled from A to F or beyond depending on the round size. Each problem comes with its own set of rules, input/output formats, and constraint descriptions. For instance, some problems specify conditions involving integer inputs for calculations or logical deductions, while others might involve more complex algorithms or data processing tasks[^3]. To find detailed information regarding contest or problem 998 specifically: - Visit the official Codeforces website. - Navigate through past contests until reaching contest 998. - Review individual problem statements under this contest for precise requirements and examples. Additionally, competitive programming platforms usually provide comprehensive documentation alongside community discussions which serve valuable resources when exploring particular challenges or learning algorithmic solutions[^2]. ```cpp // Example C++ code snippet demonstrating how contestants interact with input/output during competitions #include <iostream> using namespace std; int main() { int n; cin >> n; // Process according to problem statement specifics } ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值