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 ...
随机推荐
- windows程序 UAC设置,程序运行提示使用管理员权限运行的方法
在近期的任务中需要对光盘中的程序运行时获取管理员权限运行程序.这个功能的实现需要改变工程的配置. 在vs2015中,使用鼠标右击解决方案管理器中的工程->属性->链接器->清单文件. ...
- MapReduce源码分析之作业Job状态机解析(一)简介与正常流程浅析
作业Job状态机维护了MapReduce作业的整个生命周期,即从提交到运行结束的整个过程.Job状态机被封装在JobImpl中,其主要包括14种状态和19种导致状态发生的事件. 作业Job的全部状态维 ...
- G - Harmonic Number (II) 找规律--> 给定一个数n,求n除以1~n这n个数的和。n达到2^31 - 1;
/** 题目:G - Harmonic Number (II) 链接:https://vjudge.net/contest/154246#problem/G 题意:给定一个数n,求n除以1~n这n个数 ...
- 开源播放器ijkplayer源码结构
ijkplayer核心源码主要在ijkmedia文件夹下ijkplayer.ijksdl及ijkutils. 注:tag k0.3.1 player: remove ijkutil android相关 ...
- python 爬虫4 cookies
Cookie,指某些网站为了辨别用户身份.进行session跟踪而储存在用户本地终端上的数据(通常经过加密) 比如说有些网站需要登录后才能访问某个页面,在登录之前,你想抓取某个页面内容是不允许的.那么 ...
- jvm(13)-线程安全与锁优化
[0]README 0.1)本文部分文字转自“深入理解jvm”, 旨在学习 线程安全与锁优化 的基础知识: 0.2)本文知识对于理解 java并发编程非常有用,个人觉得,所以我总结的很详细: [1]概 ...
- MFC中调用chm帮助文档(使用相对路径)
主要就一句话: ShellExecute(NULL,L"Open",path,NULL,NULL,SW_SHOWMAXIMIZED); 常用的显示方式是SW_SHOWNORMAL和 ...
- 针对中科院java接口的用法和问题
1.下载附加的中科院分词工具包(要下载的到我的博客里面免费下载就可以) 2.解压后会看到例如以下几个目录 3.把java工程导入eclipse中.点击import.再选择existing projec ...
- Unicode与UTF-8互转(c语言和lua语言)
1. 基础 1.1 ASCII码 我们知道, 在计算机内部, 全部的信息终于都表示为一个二进制的字符串. 每个二进制 位(bit)有0和1两种状态, 因此八个二进制位就能够组合出 256种状态, 这被 ...
- 4、easyUI-七种布局(layout)
1.为网页创建边框布局 边框布局(border layout)提供五个区域:east.west.north.south.center.以下是一些通常用法: north 区域可以用来显示网站的标语. s ...