怎么说呢。。。我能说我又过了一道水题?

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)的更多相关文章

  1. Detect the Virus - ZOJ 3430(恶心的自动机)

    题目大意:给你一些病毒的特征码,然后再给一些文本,判断每个文本有多少种病毒,不过给的字符串都是加密处理过的,给的每个字符串都有对应一个64以内的一个数(题目里面那个表就是),然后可以把这个64以内的这 ...

  2. Choosing number ZOJ - 3690 (矩阵快速幂)

    题意:n个人站成一排,每个人任意从1——m中任意取一个数,要求相邻两个人的如果数字相同,数字要大于k. 分划思想推导表达式: 假设  i  个人时.第i个人的选择有两种一种是选择小于等于k的数,另一种 ...

  3. Crosses Puzzles zoj 4018 (zju校赛)

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5746 题目大意: N*M的方格里,每个格子有一个指针,一开始指向上下左右四个方 ...

  4. ZOJ 3537 (凸包 + 区间DP)(UNFINISHED)

    #include "Head.cpp" const int N = 10007; int n, m; struct Point{ int x,y; bool operator &l ...

  5. 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 ...

  6. H - Rescue the Princess ZOJ - 4097 (tarjan缩点+倍增lca)

    题目链接: H - Rescue the Princess  ZOJ - 4097 学习链接: zoj4097 Rescue the Princess无向图缩点有重边+lca - lhc..._博客园 ...

  7. 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 ...

  8. 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 / ...

  9. POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环)

    POJ 2240 Arbitrage / ZOJ 1092 Arbitrage / HDU 1217 Arbitrage / SPOJ Arbitrage(图论,环) Description Arbi ...

随机推荐

  1. fiddler和bugfree之间的联动(做伪请求、伪响应、并发、抓密码)

    青.取之于蓝,而青于蓝:冰.水为之,而寒于水 不积跬步,无以至千里;不积小流,无以成江海. 1解压Fiddler Web Debugger V4.6.2017修正中文第6版至C盘Program Fil ...

  2. centos7安装vim以及在vim中显示中文

    1.centos7安装vim yum -y install vim(简单粗暴安装方法) 2.在vim中显示中文不出现乱码 (1).vim ~/.vimrc (~/.vimrc为vim配置文件) (2) ...

  3. 最优方向法(MOD)

    算法描述 求解模型: \[\min\sum\limits_i\|x_i\|_0 \quad \mathrm{s.t.} \; \|Y-DX\|^2_F \leq \varepsilon\] 或 \[\ ...

  4. 如何解决zabbix snmp异常超时、不稳定、时通时断:Timeout

    针对平时工作中,zabbix snmp出现异常超时.不稳定.时通时断:Timeout while connecting 等的情况,以下我将以使用乐维监控为例,进行解决方案的详细叙述.   一.问题:设 ...

  5. 简介几种系统调用函数:write、read、open、close、ioctl

    在 Linux 中,一切(或几乎一切)都是文件,因此,文件操作在 Linux 中是十分重要的,为此,Linux 系统直接提供了一些函数用于对文件和设备进行访问和控制,这些函数被称为系统调用(sysca ...

  6. Trait 是什么东西

    PHP官方手册里面写的内容是 自 PHP 5.4.0 起,PHP 实现了一种代码复用的方法,称为 trait. Trait 是为类似 PHP 的单继承语言而准备的一种代码复用机制.Trait 为了减少 ...

  7. Django_信号

    目录 Django信号介绍 Django内置信号 信号种类 信号注册 自定义信号 实测 内置信号 自定义信号 Django信号介绍 Django中提供了“信号调度”,用于在框架执行操作时解耦.通俗来讲 ...

  8. js备忘录6

  9. JavaScript实现大整数减法

    继上一篇博文写了大整数加法之后,我又模拟上篇博文的算法,自己实现了大整数减法. 大整数减法相对于加法来说,稍微复杂一点.由于要考虑一些情况: 1. 两个数相减,可能会出现结果为正.负和0三种情况: 2 ...

  10. SDPA: Toward a Stateful Data Plane in Software-Defined Networking

    文章名称:SDPA: Toward a Stateful Data Plane in Software-Defined Networking 发表时间:2017 期刊来源:IEEE/ACM Trans ...