构造 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: 一开始忽略了“无需保证路径最短”这个条件,一直在套最短哈密顿通路 ...
随机推荐
- [NOIP2007] 提高组 洛谷P1005 矩阵取数游戏
题目描述 帅帅经常跟同学玩一个矩阵取数游戏:对于一个给定的n*m的矩阵,矩阵中的每个元素aij均为非负整数.游戏规则如下: 1.每次取数时须从每行各取走一个元素,共n个.m次后取完矩阵所有元素: 2. ...
- LOJ#539. 「LibreOJ NOIP Round #1」旅游路线
n<=100,m<=1000的图,在此图上用油箱容量C<=1e5的车来旅行,旅行时,走一条边会耗一单伟油,在点i时,若油量<ci,则可以把油以pi的价格补到ci,pi<= ...
- PHP PDO使用
PHP操作MySQL数据库方式有三种: *1. mysql 最原始的.纯过程化的 如连接: mysql_connect(主机名,账号,密码); 2. mysqli 改进版的.兼容过程化和面向对象化操作 ...
- Django的static和media
2013-09-09 18:13:57| 最近用到Django的静态文件,关于static和media,配置了很多次,终于可以用了. 首先是static,在'site/ ...
- 【CV论文阅读】Detecting events and key actors in multi-person videos
论文主要介绍一种多人协作的视频事件识别的方法,使用attention模型+RNN网络,最近粗浅地学习了RNN网络,它比较适合用于处理序列的存在上下文作用的数据. NCAA Basketball数据集 ...
- Vue中-下拉框可以选择可以填写
<el-form-item label="方法名称"> <el-autocomplete popper-class="my-autocomplete&q ...
- Spring_2_Spring中lazy-init和scope属性
1)springTest类: public class springTest { @Test public void instanceSpring() { AbstractApplicationCon ...
- 笔记本电脑 联想 Thinkpad E420 无法打开摄像头怎么办
1 计算机管理-右击USB视频设备(应该显示为黄色问号,表示驱动安装不成功),点击浏览计算机以查找驱动程序软件 2 选择"从计算机的设备驱动程序列表中选择",然后选择Microso ...
- react 项目实战(二)创建 用户添加 页面 及 fetch请求 json-server db.json -w -p 8000
1.安装 路由 npm install -S react-router@3.x 2.新增页面 我们现在的应用只有一个Hello React的页面,现在需要添加一个用于添加用户的页面. 首先在/src目 ...
- Trie树(Prefix Tree)介绍
本文用尽量简洁的语言介绍一种树形数据结构 -- Trie树. 一.什么是Trie树 Trie树,又叫字典树.前缀树(Prefix Tree).单词查找树 或 键树,是一种多叉树结构.如下图: 上图是一 ...