题目链接

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. Python的open函数

    打开一个文件并向其写入内容 Python的open方法用来打开一个文件.第一个參数是文件的位置和文件名称.第二个參数是读写模式.这里我们採用w模式,也就是写模式.在这样的模式下,文件原有的内容将会被删 ...

  2. hadoop工作相关

    网站点击流日志分析,客户画像,推荐系统,bi系统

  3. html+css+JavaScript贪吃蛇

    写文记录一下最近新完成的贪吃蛇游戏案例,用到了html.css和JavaScript,难度不高,适合刚入坑的同学练习,欢迎大家交流. 下面贴源码: <!DOCTYPE html> < ...

  4. apache gzip

    1.首先启动模块mod_deflate.so和mod_headers.so 2.httpd.conf #文件缓存时间配置<FilesMatch ".(flv|gif|jpg|jpeg| ...

  5. [前端开发] 未来趋势“无后端”的web应用开发模式

    最近看到前端趋势2013大会上的一篇文章,题目是<各位快看,不用后端>,觉得有点意思,恰好近期的一次讨论及半年前的一次开发实践也涉及到这种模式,简单谈谈我的想法. 不得不说,文章的题目确实 ...

  6. OpenCV学习笔记十一:opencv_ocl模块

    一,简介: 基于OpenCL优化的代码.

  7. day14 生成器的进阶

    一.生成器的两种形式  1.生成器函数的应用 # def cloth(): # for i in range(100): # yield '衣服%s'%i # # g = cloth() # for ...

  8. Tomcat工作原理解析!

    Tomcat简介   作者:杨晓(http://blog.sina.com.cn/u/1237288325) 一.Tomcat背景 自从JSP发布之后,推出了各式各样的JSP引擎.Apache Gro ...

  9. EditTextView

    package com.egojit.android.sops.views.EditText; import android.content.Context; import android.graph ...

  10. 【BZOJ2320】最多重复子串 调和级数+hash

    [BZOJ2320]最多重复子串 Description 一个字符串P的重复数定义为最大的整数R,使得P可以分为R段连续且相同的子串.比方说,“ababab”的重复数为3,“ababa”的重复数为1. ...