Codeforces Round #378 (Div. 2)D. Kostya the Sculptor
来源:互联网 发布:java soa 框架 编辑:程序博客网 时间:2024/06/05 16:19
链接:http://codeforces.com/contest/733/problem/D
题意:给定n个长方体,求一个最大的内切球的半径,可以是两块石头将两个完全匹配的面合起来的或者就用一块石头,输出切出最大内切球的那1/2个石头是哪些。
分析:我们先考虑用一块石头的最大内切球半径,一定是ans=max(min(a,b,c))。令a<=b<=c,那么如果我们想用两块石头来优化ans那么一定需要两块石头的b1c1和b2c2那个面,因为如果在这个合并的面内有a的话那么答案一定不会更优,所以我们用一个二维map存一下之前map[b][c]的最大的a即可,然后去判断合并的min(a+map[b][c],b)是否能更新ans即可。
代码:
#include<map>#include<set>#include<stack>#include<cmath>#include<queue>#include<bitset>#include<math.h>#include<vector>#include<string>#include<stdio.h>#include<cstring>#include<iostream>#include<algorithm>#pragma comment(linker, "/STACK:102400000,102400000")using namespace std;typedef double db;typedef long long ll;typedef unsigned int uint;typedef unsigned long long ull;const db eps=1e-5;const int N=1e5+10;const int M=1e5+10;const ll MOD=1000000007;const int mod=1000000007;const int MAX=1000000010;const double pi=acos(-1.0);int a[4];map<pair<int,int>,int>ma;map<pair<int,int>,int>id;int main(){ int i,n,g1=0,g2=0,mx=0; scanf("%d", &n); for (i=1;i<=n;i++) { scanf("%d%d%d", &a[1], &a[2], &a[3]); sort(a+1,a+4); if (a[1]>mx) { g1=i;g2=0;mx=a[1]; } if (min(ma[make_pair(a[2],a[3])]+a[1],a[2])>mx) { mx=min(ma[make_pair(a[2],a[3])]+a[1],a[2]); g1=id[make_pair(a[2],a[3])];g2=i; } if (a[1]>ma[make_pair(a[2],a[3])]) { ma[make_pair(a[2],a[3])]=a[1];id[make_pair(a[2],a[3])]=i; } } if (g2!=0) printf("2\n%d %d\n", g1, g2); else printf("1\n%d\n", g1); return 0;}
0 0
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor【贪心】
- Codeforces Round #378 (Div. 2)-D. Kostya the Sculptor(multiset)
- Codeforces Round #378 (Div. 2)D. Kostya the Sculptor
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor(乱搞)
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor
- Codeforces Round #378 (Div. 2) D Kostya the Sculptor
- Codeforces Round #378 (Div. 2) -- D. Kostya the Sculptor (STL水题)
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor(STL运用)
- Codeforces Round #378 (Div. 2) D. Kostya the Sculptor __ data structures、map<ii, priority_queue<ii>>
- Kostya the Sculptor Codeforces Round#378-D(逻辑+排序)
- 【25.47%】【codeforces 733D】Kostya the Sculptor
- 【Codeforces 733D】 Kostya the Sculptor【贪心】
- Codeforces 733D Kostya the Sculptor 贪心
- codeforces 733D Kostya the Sculptor
- Codeforces 733D Kostya the Sculptor
- CodeForces 733D Kostya the Sculptor
- codeforces 733D. Kostya the Sculptor
- CodeForces 733D - Kostya the Sculptor
- 【c++基础】虚函数的使用以及和成员函数的区别
- 设计模式的六大原则
- 如何把MATLAB编译成C++模块
- httpost请求间隔两秒
- 数据统计sql语句
- Codeforces Round #378 (Div. 2)D. Kostya the Sculptor
- Android使用iText生成pdf文件并读取pdf内容
- hive仓库远程链接:Peer indicated failure: Unsupported mechanism type PLAIN (state=08S01,code=0)
- Python多进程编程
- shinyapps安装部署
- Mysql指定字符集创建数据库
- OBS源码阅读笔记--32位的无法检测摄像头问题
- 文字倒影
- map用法大全