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

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. Print Spooler 服务自动停止

    1)先在服务里停止并禁用Print Spooler : 2)删除此文件夹下的所有文件,C:\Windows\System32\spool\PRINTERS\ : 3)删除注册表 HKEY_LOCAL_ ...

  2. SURF算法的一篇翻译与论证

    原文地址:http://www.sohu.com/a/157742015_715754 SURF: Speeded Up Robust Features 摘要 本文提出了一种新型的具有尺度和旋转不变特 ...

  3. halcon二 图像校正

    1.get_image_size(Image : : : Width, Height) 返回图像的尺寸. 2.parameters_image_to_world_plane_centered (Cam ...

  4. NO--16 vue之父子组件传值

    先创建项目并运行 vue init webpack-simple templatecd templatenpm inpm run dev 一.子组件访问父组件的数据 方式一 :子组件直接访问父组件的数 ...

  5. 三种UIScrollView嵌套实现方案

    背景 随着产品功能不断的迭代,总会有需求希望在保证不影响其他区域功能的前提下,在某一区域实现根据选择器切换不同的内容显示. 苹果并不推荐嵌套滚动视图,如果直接添加的话,就会出现下图这种情况,手势的冲突 ...

  6. (1) Python 数据类型功能

    1.int 将字符串转化为数字 a="123"  print(type(a),a) b=int(a)  print(type(b),b) num="0011" ...

  7. CHAPTER 8 Out of Darkness 第8章 走出黑暗

    CHAPTER 8 Out of Darkness 第8章 走出黑暗 We expect scientists to be trying to discover new things, and for ...

  8. ats Linux Bridge内联

    Linux可以配置为在桥接模式下运行. 为网桥分配了两个或更多物理接口. 在接口之间共享单个IP地址. 默认情况下,任何到达一个接口的数据包都会立即路由到另一个网桥接口. 需要的Linux包: bri ...

  9. 【Kubernetes】基于角色的权限控制:RBAC

    Kubernetes中所有的API对象,都保存在Etcd里,对这些API对象的操作,一定都是通过访问kube-apiserver实现的,原因是需要APIServer来做授权工作. 在Kubernete ...

  10. mongoose和mongodb的几篇文章 (ObjectId,ref)

    http://mongoosejs.com/docs/populate.html http://stackoverflow.com/questions/6578178/node-js-mongoose ...