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 ...
随机推荐
- 14-Dockerfile常用指令
下面列出了 Dockerfile 中最常用的指令,完整列表和说明可参看官方文档.FROM 指定 base 镜像. MAINTAINER设置镜像的作者,可以是任意字符串. COPY将文件从 build ...
- Centos7+安装python3+wkhtmltoPdf+pdfkit
前言 这几天要做一个将HTML转化为PDF的小功能.期间经历了颇多的挫折,刚开始是通过java做的,后来发现java库做这个事情实在是效果不理想,前端做好了样式转完之后会出现很多问题.后来我想起来py ...
- 比较undefined和“undefined”
说实话,它们之间的区别挺明显的,我们一般认为undefined是JavaScript提供的一个“关键字”,而“undefined”却是一个字符串,只是引号的内容和undefined一样. undefi ...
- 记一次nginx -t非常慢的排障经历
在一次修改nginx配置时候,执行 case: #/usr/local/nginx/sbin/nginx -t 出现执行命令出现很久没返回结果,也没返回成功或是失败,就是一直卡住的状态,严重影响ngi ...
- nodejs 中 module.exports 和 exports 的区别
1. module应该是require方法中,上下文中的对象 2. exports对象应该是上下文中引用module.exports的新对象 3. exports.a = xxx 会将修改更新到mod ...
- numastat命令详解
基础命令学习目录 作者:[吴业亮]博客:http://blog.csdn.net/wylfengyujiancheng一.系统架构的演进从SMP到NUMA1.SMP(Symmetric Multi-P ...
- 深入理解JavaScript函数参数
前面的话 javascript函数的参数与大多数其他语言的函数的参数有所不同.函数不介意传递进来多少个参数,也不在乎传进来的参数是什么数据类型,甚至可以不传参数. arguments javascri ...
- 44 道 JavaScript 难题(JavaScript Puzzlers!)
JavaScript Puzzlers原文 1. ["1", "2", "3"].map(parseInt) 答案:[1, NaN, NaN ...
- PLSQL Developer windows 64位连接数据库的问题
使用PLSQL Developer 工具连接到数据库进行开发,目前主流windows 系统都是64位操作系统,而PLSQL Developer 只有32位程序,所以在连接数据库上遇到一些问题. PL ...
- 网络助手之NABCD
Sunny--Code团队:刘中睿,杜晓松,郑成 我们小组这次做的软件名字叫为校园网络助手.它主要有着两项功能:网络助手与校内网盘. N--need:在学校里有时候我们就 ...