What Kind of Friends Are You? ZOJ - 3960(ZheJiang Province Contest)
怎么说呢。。。我能说我又过了一道水题?
emm。。。
问题描述:
给定 n 个待确定名字的 Friends
和 q 个问题。已知 c 个 Friends
的名字。
对于第 i 个问题,有 个 Friends
会回答 yes
,其余 个 Friends
均回答 no
。
现在给定 n 个待确定名字的 Friends
以及他们对于 q 个问题的回答。若能够确定它的名字,给出;否则,输出 Let's Go to the library!!
思路:
对于回答yes的,在当前人结果上加1,而回答no时就把该friend里面的名字之外的名字加1,最后如果某个人的计数为friend的个数,就有可能是这个人,但是如果好几个符合条件的肯定就不能确定了!
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
map<string, int> mapp;
int tlb[][];
int res[maxn];
string str;
string num[maxn]; int main()
{
int T;
int n, m, c;
rd(T);
while(T--)
{
mem(tlb, );
scanf("%d%d%d", &n, &m, &c);
rap(i, , c)
{
cin>> num[i];
mapp[num[i]] = i;
}
rap(i, , m)
{
int q;
rd(q);
rap(j, , q)
{
cin>> str;
tlb[i][mapp[str]] = ;
}
}
int tmp;
rap(i, , n)
{
mem(res, );
rap(j, , m)
{
rd(tmp);
tmp = tmp?:-;
rap(k, , c)
if(tlb[j][k])
res[k] += tmp;
if(tmp == -)
rap(k, , c)
res[k]++;
}
int flag = , id = ;
rap(j, , c)
{
// cout<< res[j] <<endl;
if(res[j] == m && flag)
{
flag++;
break;
}
if(res[j] == m) flag++, id = j;
} if(flag == ) cout<< num[id] <<endl;
else cout<< "Let's go to the library!!" <<endl; } } return ;
}
What Kind of Friends Are You? ZOJ - 3960(ZheJiang Province Contest)的更多相关文章
- Detect the Virus - ZOJ 3430(恶心的自动机)
题目大意:给你一些病毒的特征码,然后再给一些文本,判断每个文本有多少种病毒,不过给的字符串都是加密处理过的,给的每个字符串都有对应一个64以内的一个数(题目里面那个表就是),然后可以把这个64以内的这 ...
- Choosing number ZOJ - 3690 (矩阵快速幂)
题意:n个人站成一排,每个人任意从1——m中任意取一个数,要求相邻两个人的如果数字相同,数字要大于k. 分划思想推导表达式: 假设 i 个人时.第i个人的选择有两种一种是选择小于等于k的数,另一种 ...
- Crosses Puzzles zoj 4018 (zju校赛)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5746 题目大意: N*M的方格里,每个格子有一个指针,一开始指向上下左右四个方 ...
- ZOJ 3537 (凸包 + 区间DP)(UNFINISHED)
#include "Head.cpp" const int N = 10007; int n, m; struct Point{ int x,y; bool operator &l ...
- ZOJ 3529 A Game Between Alice and Bob(博弈论-sg函数)
ZOJ 3529 - A Game Between Alice and Bob Time Limit:5000MS Memory Limit:262144KB 64bit IO For ...
- H - Rescue the Princess ZOJ - 4097 (tarjan缩点+倍增lca)
题目链接: H - Rescue the Princess ZOJ - 4097 学习链接: zoj4097 Rescue the Princess无向图缩点有重边+lca - lhc..._博客园 ...
- HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径)
HDU 1069 Monkey and Banana / ZOJ 1093 Monkey and Banana (最长路径) Description A group of researchers ar ...
- POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / SCU 1132 Invitation Cards / ZOJ 2008 Invitation Cards / HDU 1535 (图论,最短路径)
POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / ...
- POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环)
POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环) Description Arbi ...
随机推荐
- 常见的浏览器端的存储技术:cookie
工作原理: cookie是存在用户硬盘中,用户每次访问站点时,Web应用程序都可以读取Cookie包含的信息.当用户再次访问这个站点时,浏览器就会在本地硬盘上查找与该 URL 相关联的 Cookie. ...
- linux 查看服务器序列号
1.安装工具 dmidecode yum install dmidecode -y 2.使用 dmidecode -t 1
- 16节实用性爆棚的Ps课:零基础秒上手,让你省钱也赚钱
ps视频教程,ps自学视频教程.ps免费视频教程下载,16节实用性爆棚的Ps课教程视频内容较大,分为俩部分: 16节实用性爆棚的Ps课第一部分:百度网盘,https://pan.baidu.com/s ...
- 腾讯云服务器linux centOS7.4 搭建ftp服务器 vsftpd
腾讯云服务器linux centos 7.4 搭建ftp服务器 vsftpd 在centos 7.3测试也是OK的,其它版本没有实验 # 安装 vsftpd $ yum install vsftpd ...
- alibaba/fescar 阿里巴巴 开源 分布式事务中间件
Fescar 是 阿里巴巴 开源的 分布式事务中间件,以 高效 并且对业务 0 侵入 的方式,解决 微服务 场景下面临的分布式事务问题. 示例:https://github.com/windwant/ ...
- c++三大概念要分清--重载,隐藏(重定义),覆盖(重写)
重载,隐藏(重定义),覆盖(重写)—这几个名词看着好像很像,不过其实一样都不一样!! 综述: 说明:覆盖中的访问修饰符可以不同是指可以不用显示地用virtual:当访问修饰符改为const或者stat ...
- javascript this(上)
javascript的this指向的是一个函数运行时动态绑定对象. this的4种常见的指向: 作为对象的方法调用 var obj={ name:"姚小白", getName:fu ...
- 经典的性能优化最佳实践 web性能权威指南 读书笔记
web性能权威指南 page 203 经典的性能优化最佳实践 无论什么网络,也不管所用网络协议是什么版本,所有应用都应该致力于消除或减 少不必要的网络延迟,将需要传输的数据压缩至最少.这两条标准是经典 ...
- hdfs命令大全
hdfs常用命令: 第一部分:hdfs文件系统命令 第一类:文件路径增删改查系列: hdfs dfs -mkdir dir 创建文件夹 hdfs dfs -rmr dir 删除文件夹dir hdf ...
- OSSEC 架构
OSSEC由很多部分组成,它有一个集中的管理端,用于监控.并接收来自代理.syslog.数据库或无代理设备的日志. 管理端(服务器) 管理端属于OSSEC部署中的中心部分.它存储了文件完整性检测数据库 ...