ZOJ 3960 What Kind of Friends Are You? 【状态标记】
题目链接
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3960
题意
首先给出 一系列名字 需要辨别的名字,然后给出Q个问题,每个问题有 若干个人给出答案,给出答案的人 此时状态 为1 没有给出答案 的 状态为0
最后给出 三个需要辨识的状态,如果有且只有一个人 跟这个状态相同 就输出这个人的名字
AC代码
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long LL;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, q;
int i, j;
scanf("%d%d", &n, &q);
map <string, string> M;
M.clear();
string s, temp = "";
for (i = 0; i < q; i++)
temp += "0";
int m;
scanf("%d", &m);
for (i = 0; i < m; i++)
{
cin >> s;
M[s] = temp;
}
for (i = 0; i < q; i++)
{
scanf("%d", &m);
for (j = 0; j < m; j++)
{
cin >> s;
M[s][i] = '1';
}
}
// map <string, string>::iterator it;
// for (it = M.begin(); it != M.end(); it++)
// cout << it -> first << " " << it -> second << endl;
string ans;
int num;
for (i = 0; i < n; i++)
{
temp.clear();
for (j = 0; j < q; j++)
{
scanf(" %d", &num);
temp += num + '0';
}
int flag = 0;
ans.clear();
map <string, string>:: iterator it;
for (it = M.begin(); it != M.end(); it++)
{
if (it -> second == temp )
{
if (flag == 1)
{
flag = 0;
break;
}
else
{
flag = 1;
ans = it -> first;
}
}
}
if (flag)
cout << ans << endl;
else
printf("Let's go to the library!!\n");
}
}
}
ZOJ 3960 What Kind of Friends Are You? 【状态标记】的更多相关文章
- 2017浙江省赛 C - What Kind of Friends Are You? ZOJ - 3960
地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3960 题目: Japari Park is a large zoo ...
- What Kind of Friends Are You? ZOJ 3960
比赛的时候用vector交集做的...情况考虑的不全面 wrong到疯 赛后考虑全了情况....T了 果然 set_intersection 不能相信 嗯 不好意思 交集a了 第二个代码 求出来 ...
- ZOJ 3960 What Kind of Friends Are You?(读题+思维)
题目链接 :http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5592 Japari Park is a large zoo hom ...
- What Kind of Friends Are You? ZOJ - 3960(ZheJiang Province Contest)
怎么说呢...我能说我又过了一道水题? emm... 问题描述: 给定 n 个待确定名字的 Friends 和 q 个问题.已知 c 个 Friends 的名字. 对于第 i 个问题,有 个 Fri ...
- zoj 3960 What Kind of Friends Are You?(哈希)
What Kind of Friends Are You? Time Limit: 1 Second Memory Limit: 65536 KB Japari Park is a larg ...
- ZOJ 3960:What Kind of Friends Are You?
What Kind of Friends Are You? Time Limit: 1 Second Memory Limit: 65536 KB Japari Park is a large zoo ...
- HDU 1400 (POJ 2411 ZOJ 1100)Mondriaan's Dream(DP + 状态压缩)
Mondriaan's Dream Problem Description Squares and rectangles fascinated the famous Dutch painter Pie ...
- ZOJ - 3954 Seven-Segment Display 【状态标记】
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3954 题意 有一块 LED 灯 然后上面有七块灯管 在显示不同数 ...
- poj 1080 zoj 1027(最长公共子序列变种)
http://poj.org/problem?id=1080 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=27 /* zoj ...
随机推荐
- layui动态渲染生成select的option值
脚本语言:设定默认值:直接拼接,然后根据返回值渲染select// 动态渲染脚本类型下拉框 // 1.发送ajax请求得到data // 2.将data渲染到页面上 function getDataL ...
- 参数化--每个vuser使用不同的参数值
使用controller并发时,每个vuser从参数文件中取一个值,设置如下图:
- Spring @Transactional
在service类前加上@Transactional,声明这个service所有方法需要事务管理.每一个业务方法开始时都会打开一个事务. Spring默认情况下会对运行期例外(RunTimeExcep ...
- keypad代码分析
keypad作为input设备注册到内核,与platform总线驱动match. 1.描述一个输入设备对象 static struct input_dev *kpd_input_dev; 告知输入子系 ...
- IOS设计模式浅析之适配器模式(Adapter)
引言 在项目开发中,有时候会遇到这样的一种情景:需要使用以前开发的“一些现存的对象”,但是新环境中要求的接口是这些现存对象所不满足的.怎样应对这种迁移的需求?使得可以复用这些对象,以满足新的应用环境, ...
- IOS设计模式浅析之外观模式(Facade)
引言 在项目开发中,有时候会遇到这样的一种情景:已有系统的各个子系统之间,随着业务需求的发展,有了比较紧凑的耦合关系.现在需要利用这些子系统的功能,为移动端提供业务处理.我们该怎么应对这样的业务需求呢 ...
- ps -aux --sort -rss |head 列出进程拿物理内存占用排序 使用ps aux 查看系统进程时,第六列即 RSS列显示的就是进程使用的物理内存。
ps -a Select all processes -u userlist Select by effective user ID (EUID) or name. ...
- 浅谈web前端安全
单纯地在你的客户端弹出信息只是类似于迫使你在自己的房间脱衣服--没人看得到,自然也不算啥恶意行为.那么如果我把你的信息通过脚本发送到我的服务器保存起来呢?先放心,我不打算这么做,也没那笔闲钱去购置一个 ...
- DWR相关知识
解决问题:服务器给前台推送消息 用途:聊天,微信签到墙,设备报警
- Android.mk 输出日志 调试
$(warning "the value of MY_FILES_PATH is $(MY_FILES_PATH)") #jni