题目链接

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? 【状态标记】的更多相关文章

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

  2. What Kind of Friends Are You? ZOJ 3960

    比赛的时候用vector交集做的...情况考虑的不全面  wrong到疯 赛后考虑全了情况....T了 果然 set_intersection  不能相信 嗯 不好意思 交集a了  第二个代码 求出来 ...

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

  4. What Kind of Friends Are You? ZOJ - 3960(ZheJiang Province Contest)

    怎么说呢...我能说我又过了一道水题? emm... 问题描述: 给定 n 个待确定名字的 Friends 和 q 个问题.已知 c 个 Friends 的名字. 对于第 i 个问题,有  个 Fri ...

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

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

  7. HDU 1400 (POJ 2411 ZOJ 1100)Mondriaan's Dream(DP + 状态压缩)

    Mondriaan's Dream Problem Description Squares and rectangles fascinated the famous Dutch painter Pie ...

  8. ZOJ - 3954 Seven-Segment Display 【状态标记】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3954 题意 有一块 LED 灯 然后上面有七块灯管 在显示不同数 ...

  9. poj 1080 zoj 1027(最长公共子序列变种)

    http://poj.org/problem?id=1080 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=27 /* zoj ...

随机推荐

  1. 在CTreeCtrl控件点击事件中获取点击的项

    网上搜了一下,有两种方法: 1.使用GetSelectedItem() HTREEITEM hItem = m_treeCtrl.GetSelectedItem(); CString strText ...

  2. Unity3D - LINEAR INTERPOLATION

    原文地址:http://unity3d.com/learn/tutorials/modules/beginner/scripting/linear-interpolation 水平有限,翻译粗略,欢迎 ...

  3. Oracle----oracle小知识总结

    1,表列的五种约束 not null, unique,primary key, foreign key, check 2,权限分配 grant 权限 on 表 to 用户 3,表和视图的区别 视图是一 ...

  4. 访问JavaBean

    <jsp:useBean> 标签可以在JSP中声明一个JavaBean,然后使用.声明后,JavaBean对象就成了脚本变量,可以通过脚本元素或其他自定义标签来访问.<jsp:use ...

  5. 怎么获取Android应用程序的上下文

    在一个应用里面,有很多activity,而这些activity之间经常要进行互相启动.往复跳转.还有就是通过Notification启动.当activity多了之后,如果设置他的模式为单例模式,或者不 ...

  6. Unity如何判断网络连接类型

    今天遇到了一个问题,如何判断手机游戏当前的网络连接类型,是wifi还是234G? 起初准备在Android中写好插件供Unity调用,后来在网上浏览众神的帖子时,在csdn上看到了使用NetworkR ...

  7. 关于dll的pdb文件的小贴士

    .pdb文件最好与生成它的.dll文件放在一起,这样调试的时候才有可能跟踪进dll的内部函数里.

  8. CStdioFile UNICODE编译 读取中文汉字乱码 .

    函数原形为:char *setlocale( int category, const char *locale );头文件:<locale.h>所支持的操作系统为:ANSI, Win 95 ...

  9. iOS 。开发之指纹识别功能

    // 头文件导入 #import <LocalAuthentication/LocalAuthentication.h> //在iPhone5s的时候,苹果推出了指纹解锁.但是在ios8. ...

  10. Linux学习目录

    一.CentOS for Linux 大神博客:骏马金龙  Linux也可以参考,这篇博客进行学习 http://www.cnblogs.com/f-ck-need-u/p/7048359.html ...