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 ...
随机推荐
- 在linux中使用sqlplus的上下左右箭头的方法
在linux下面使用sqlpus连接数据库处理,实在不是很方便,还好有一个工具rlwrap,通过这个能够调用历史命令和回调功能,能够极大的提高效率. 1. 下载 从http://utopia.know ...
- Linux 进程创建二(execve和wait)
三:execve系统调用 int execve(const char *filename, char *const argv[],char *const envp[]); fork创建了一个新的进程, ...
- php5.4n 长链接 bug
运行5.2的部分程序会有中文无法显示的问题 恢复到5.2后中文显示正常
- 微信 oauth授权2
2.前面请求成功后 会在跳转url后得到 ?code=00b788e3b42043c8459a57a8d8ab5d9f&state=1 3.之后 使用code换取access_token 换取 ...
- Intent跳转系统的应用
1.从google搜索内容 Intent intent = new Intent(); intent.setAction(Intent.ACTION_WEB_SEARCH); int ...
- 实现 iPhone 电子书的分页显示功能的代码
本文转载至 http://blog.csdn.net/zaitianaoxiang/article/details/6650497 原文地址:实现 iPhone 电子书的分页显示功能的代码作者:醉吻 ...
- 【BZOJ4817】[Sdoi2017]树点涂色 LCT+线段树
[BZOJ4817][Sdoi2017]树点涂色 Description Bob有一棵n个点的有根树,其中1号点是根节点.Bob在每个点上涂了颜色,并且每个点上的颜色不同.定义一条路径的权值是:这条路 ...
- EasyDSS流媒体服务器软件支持HTTPS-启用https服务申请免费证书
EasyDSS流媒体服务器软件,提供一站式的转码.点播.直播.时移回放服务,极大地简化了开发和集成的工作. 其中,点播功能主要包含:上传.转码.分发.直播功能,主要包含:直播.录像, 直播支持RTMP ...
- String、StringBuffer与StringBuilder的区别。
无论是做Java或是Android,都避免不了遇到这个问题,其实开发过程中一般情况下是不会纠结,这个问题是面试必选经典题,今天有时间,就总结一下. String.StringBuffer.String ...
- JavaScript和jQuery改变标签内容
HTML: <div id="mazey">content</div> JavaScript: var mazey=document.getElementB ...