构造 Codeforces Round #107 (Div. 2) B. Phone Numbers
/*
构造:结构体排个序,写的有些啰嗦,主要想用用流,少些了判断条件WA好几次:(
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <iostream>
#include <string>
using namespace std; const int MAXN = 1e2 + ;
const int INF = 0x3f3f3f3f;
struct Phone
{
string name;
string num[MAXN];
int tot, t, p, g, id;
}p[MAXN]; bool cmp_t(Phone x, Phone y)
{
if (x.t == y.t) return x.id < y.id;
return x.t > y.t;
} bool cmp_p(Phone x, Phone y)
{
if (x.p == y.p) return x.id < y.id;
return x.p > y.p;
} bool cmp_g(Phone x, Phone y)
{
if (x.g == y.g) return x.id < y.id;
return x.g > y.g;
} int main(void) //Codeforces Round #107 (Div. 2) B. Phone Numbers
{
// freopen ("C.in", "r", stdin); int n;
while (cin >> n)
{
for (int i=; i<=n; ++i)
{
cin >> p[i].tot >> p[i].name; p[i].id = i;
p[i].t = p[i].p = p[i].g = ;
for (int j=; j<=p[i].tot; ++j)
{
cin >> p[i].num[j];
if (p[i].num[j][] == p[i].num[j][] && p[i].num[j][] == p[i].num[j][] &&
p[i].num[j][] == p[i].num[j][] && p[i].num[j][] == p[i].num[j][] &&
p[i].num[j][] == p[i].num[j][]) p[i].t++;
else if (p[i].num[j][] > p[i].num[j][] && p[i].num[j][] > p[i].num[j][] &&
p[i].num[j][] > p[i].num[j][] && p[i].num[j][] > p[i].num[j][] &&
p[i].num[j][] > p[i].num[j][]) p[i].p++;
}
p[i].g = p[i].tot - p[i].t - p[i].p;
// cout << p[i].t << " " << p[i].p << " " << p[i].g << endl;
} int pre = ;
sort (p+, p++n, cmp_t);
cout << "If you want to call a taxi, you should call: ";
for (int i=; i<=n; ++i)
{
if (i == )
{
cout << p[i].name; pre = p[i].t;
}
else if (p[i].t == pre) cout << ", " << p[i].name;
else break;
}
cout << "." << endl;
sort (p+, p++n, cmp_p);
cout << "If you want to order a pizza, you should call: ";
for (int i=; i<=n; ++i)
{
if (i == )
{
cout << p[i].name; pre = p[i].p;
}
else if (p[i].p == pre) cout << ", " << p[i].name;
else break;
}
cout << "." << endl;
sort (p+, p++n, cmp_g);
cout << "If you want to go to a cafe with a wonderful girl, you should call: ";
for (int i=; i<=n; ++i)
{
if (i == )
{
cout << p[i].name; pre = p[i].g;
}
else if (p[i].g == pre) cout << ", " << p[i].name;
else break;
}
cout << "." << endl;
} return ;
} /*
If you want to call a taxi, you should call: Rogulenko.
If you want to order a pizza, you should call: Fedorov, Rogulenko, Kaluzhin.
If you want to go to a cafe with a wonderful girl, you should call: Melnikov.
*/
构造 Codeforces Round #107 (Div. 2) B. Phone Numbers的更多相关文章
- 构造 Codeforces Round #302 (Div. 2) B Sea and Islands
题目传送门 /* 题意:在n^n的海洋里是否有k块陆地 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 输出完k个L后,之后全部输出S:) 5 10 的例子可以是这样的: LSLS ...
- 构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers
题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少 ...
- 构造 Codeforces Round #Pi (Div. 2) B. Berland National Library
题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况 ...
- 暴力+构造 Codeforces Round #283 (Div. 2) C. Removing Columns
题目传送门 /* 题意:删除若干行,使得n行字符串成递增排序 暴力+构造:从前往后枚举列,当之前的顺序已经正确时,之后就不用考虑了,这样删列最小 */ /*********************** ...
- 贪心+构造 Codeforces Round #277 (Div. 2) C. Palindrome Transformation
题目传送门 /* 贪心+构造:因为是对称的,可以全都左一半考虑,过程很简单,但是能想到就很难了 */ /************************************************ ...
- 构造 Codeforces Round #275 (Div. 2) C. Diverse Permutation
题目传送门 /* 构造:首先先选好k个不同的值,从1到k,按要求把数字放好,其余的随便放.因为是绝对差值,从n开始一下一上, 这样保证不会超出边界并且以防其余的数相邻绝对值差>k */ /*** ...
- 构造 Codeforces Round #135 (Div. 2) B. Special Offer! Super Price 999 Bourles!
题目传送门 /* 构造:从大到小构造,每一次都把最后不是9的变为9,p - p MOD 10^k - 1,直到小于最小值. 另外,最多len-1次循环 */ #include <cstdio&g ...
- Codeforces Round #107 (Div. 1) B. Quantity of Strings(推算)
http://codeforces.com/problemset/problem/150/B 题意: 给出n,m,k,n表示字符串的长度为n,m表示字符种类个数,k表示每k个数都必须是回文串,求满足要 ...
- 构造 - Codeforces Round #319 (Div. 1)C. Points on Plane
Points on Plane Problem's Link Mean: 在二维坐标中给定n个点,求一条哈密顿通路. analyse: 一开始忽略了“无需保证路径最短”这个条件,一直在套最短哈密顿通路 ...
随机推荐
- jquery如何通过ajax请求获取后台数据显示在表格上
1.引入bootstrap和jquery的cdn <link rel="stylesheet" type="text/css" href="ht ...
- bzoj1834 网络扩容 网络流
好久没写题解了啊··· 题目大意: 给你一幅n个点的网络,先求出其1到n的最大流,每条弧还会有个属性\(cost_i\),表示没扩容一个单位的费用,现在我们要求的就是扩容K个单位的最小费用 思路: 这 ...
- 【http_load】http_load性能测试工具使用详解
1.什么是http_loadhttp_load是一款基于Linux平台的web服务器性能测试工具,用于测试web服务器的吞吐量与负载,web页面的性能. 2.http_load的安装1)下载地址wge ...
- Errors running builder 'JavaScript Validator' on
eclipse编译提示Errors running builder 'JavaScript Validator' on 解决方法见下图 去掉 'JavaScript Validator' 即可
- 我的arcgis培训照片4 来自http://www.cioiot.com/successview-549-1.html
- Hadoop 知识
Map Reduce & YARN 简介 Apache Hadoop 是一个开源软件框架,可安装在一个商用机器集群中,使机器可彼此通信并协同工作,以高度分布式的方式共同存储和处理大量数据.最初 ...
- RHEL6.5上Oracle ACFS与Linux samba一起使用时遇到的bug
RHEL上的Oracle ACFS与linux samba一起使用时遇到的bug 一.环境介绍: cat /etc/issue的结果为: Red Hat Enterprise Linux Server ...
- 【CERC2008】【BZOJ4319】Suffix reconstruction
Description 话说练习后缀数组时,小C 刷遍 poj 后缀数组题. 各类字符串题闻之丧胆.就在准备对敌方武将发出连环杀时,对方一记无中生有,又一招顺 手牵羊.小C 程序中的原字符数组就被牵走 ...
- Linux 内核开发 - 内存管理
1.1什么是内存管理 内存管理是对计算机内存进行分配和使用的技术.内存管理主要存在于多任务的操作系统中,因为内存资源极其有限.须要在不同的任务之间共享内存,内存管理的存在就是要高效.高速的非配内存,并 ...
- java UDP聊天与文件传输
package rgy.com.UDP3; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.Action ...