构造 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: 一开始忽略了“无需保证路径最短”这个条件,一直在套最短哈密顿通路 ...
随机推荐
- 【electron系列之一】创建右下角通知栏小图标
electron 用Tray对象来实现右下角通知栏小图标 一.先引入app, BrowserWindow来实现浏览器功能,接着引入Tray, Menu来实现右下角 二. new Tray('./pag ...
- [Sqlite3] Sqlite Introduction
Check whether you have sqlite3 installed: sqlite3 -version To create a new db: sqlite3 <filename. ...
- 改动ScrollView的滑动速度和解决ScrollView与ViewPager的冲突
话不多说,非常easy,能够从凝视中知道做法,直接上代码: 1.改动ScrollView的滑动速度: public class MyHorizontalScrollView extends Horiz ...
- USRP内部的寄存器
usrp_regs.hpp #ifndef INCLUDED_USRP2_REGS_HPP #define INCLUDED_USRP2_REGS_HPP ////////////////////// ...
- 网页设计中11 款最好CSS框架
网页设计和发展领域已经成为竞争激烈的虚拟世界.想要在网络的虚拟世界中生存,仅有一堆静止的在线网络应用是远远不够的,网页必须要有很多功能,配以让人无法抗拒的设计.网页编码一定要合适.精确,才能保证不发生 ...
- iOS CMSampleBuffer deep copy
extension CVPixelBuffer { func copy() -> CVPixelBuffer { precondition(CFGetTypeID(self) == CVPixe ...
- linux switch_root
1 命令格式 switch_root newroot init 跳转到另外一个文件系统,并且把newroot作为新的mount tree,并且执行init程序. 2 特殊要求 newroot必须是一个 ...
- doGet() throws NamingException报错
做一个通过JNDI查找资源的小练习,Context = new InitialContext(),发现NamingException异常,eclipse编辑器只有catch的提示,没有throws的提 ...
- session 生命周期
以前看到书上session 的生命周期,知道session的生命周期是在第一次访(即打开浏览器输入地址成功访问)的时候被创建.同时HttpSessionListener接口的sessionCreate ...
- node inspector的安装以及使用【已经淘汰了】
https://github.com/node-inspector/node-inspector 前提 1.npm install -g node-pre-gyp https://github.com ...