比赛的时候用vector交集做的。。。情况考虑的不全面  wrong到疯

赛后考虑全了情况。。。。T了 果然 set_intersection  不能相信

嗯 不好意思 交集a了  第二个代码

求出来每个1的交集

为0的时候  要减去相同的元素 看最后一个案例的B和K的输出想想为什么

另一个做法就是处理出每个人名的序列

然后输入序列的时候去找一样的 如果只有一个

那就是它了

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <list>
#include <cmath>
#include <bitset>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define rb(a) scanf("%lf", &a)
#define rf(a) scanf("%f", &a)
#define pd(a) printf("%d\n", a)
#define plld(a) printf("%lld\n", a)
#define pc(a) printf("%c\n", a)
#define ps(a) printf("%s\n", a)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
int n, q, c, m;
map<string, string> mapp;
map<string, int> mapp2;
string str[maxn];
int main()
{
int T;
rd(T);
while(T--)
{
rd(n), rd(q);
rd(c);
mapp.clear();
string name;
for(int i = ; i < c; i++)
{
cin >> str[i];
}
for(int i = ; i <= q; i++)
{
rd(m);
mapp2.clear();
for(int j = ; j < m; j++)
{
cin >> name;
mapp[name] += "";
mapp2[name] = ;
}
for(int j = ; j < c; j++)
{
if(!mapp2[str[j]])
mapp[str[j]] += "";
if(i != q)
mapp[str[j]] += " ";
}
}
getchar();
string str1, str2;
for(int i = ; i <= n; i++)
{
int cnt = ;
getline(cin, str1);
for(int j = ; j < c; j++)
{
if(mapp[str[j]] == str1)
cnt++, str2 = str[j];
}
if(cnt == )
cout << str2 << endl;
else
printf("Let's go to the library!!\n"); } } return ;
}
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <list>
#include <cmath>
#include <bitset>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define rb(a) scanf("%lf", &a)
#define rf(a) scanf("%f", &a)
#define pd(a) printf("%d\n", a)
#define plld(a) printf("%lld\n", a)
#define pc(a) printf("%c\n", a)
#define ps(a) printf("%s\n", a)
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff; vector<string> G[maxn];
int n, q, c, m;
vector<string> v, v1;
int main()
{
int T;
rd(T);
while(T--)
{
rd(n), rd(q);
rd(c);
for(int i = ; i <= q + ; i++) G[i].clear();
string name;
for(int i = ; i < c; i++)
{
cin >> name;
G[].push_back(name);
}
sort(G[].begin(), G[].end());
for(int i = ; i <= q; i++)
{
rd(m);
for(int j = ; j < m; j++)
cin >> name, G[i].push_back(name);
sort(G[i].begin(), G[i].end());
}
for(int i = ; i <= n; i++)
{
v.clear();
v = G[];
int ans = ;
for(int j = ; j <= q; j++)
{
int tmp;
rd(tmp);
if(tmp == )
{
ans++; set_intersection(v.begin(), v.end(), G[j].begin(), G[j].end(), back_inserter(v1));
v.clear();
v = v1;
v1.clear(); sort(v.begin(), v.end());
}
else
{
set_intersection(v.begin(), v.end(), G[j].begin(), G[j].end(), back_inserter(v1));
for(int k = ; k < v1.size(); k++)
{
v.erase(find(v.begin(), v.end(), v1[k]));
}
v1.clear();
}
}
if(v.size() == )
{
cout << v[] << endl;
}
else
{
printf("Let's go to the library!!\n"); } }
} return ;
}

What Kind of Friends Are You? ZOJ 3960的更多相关文章

  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. ZOJ 3960 What Kind of Friends Are You? 【状态标记】

    题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3960 题意 首先给出 一系列名字 需要辨别的名字,然后给出Q个问 ...

  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. HZNU Training 4 for Zhejiang Provincial Collegiate Programming Contest 2019

    今日这场比赛我们准备的题比较全面,二分+数论+最短路+计算几何+dp+思维+签到题等.有较难的防AK题,也有简单的签到题.为大家准备了一份题解和AC代码. A - Meeting with Alien ...

  8. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  9. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

随机推荐

  1. [转] 以后再有人问你selenium是什么,你就把这篇文章给他

    本文转自:https://blog.csdn.net/TestingGDR/article/details/81950593 写在最前面:目前自动化测试并不属于新鲜的事物,或者说自动化测试的各种方法论 ...

  2. Winform宽度与高度

    获取代码 非实时:一开始的宽度是多少就多少,拉宽了 获取的宽度还是刚开始的 ,同理高度 this.Width this.Height 获取代码 实时:调了窗体高度宽度,宽度 高度 也跟着变化,不再保持 ...

  3. 图片与Base64相互转换 jar包

    1.右键项目 -->Properties -->Java Bulid Path-> Libraries -->JRE System Library-->Access ru ...

  4. JavaScript 是如何工作的:JavaScript 的共享传递和按值传递

    摘要: 原始数据类型和引用数据类型的副本作为参数传递给函数. 原文:JavaScript 是如何工作的:JavaScript 的共享传递和按值传递 作者:前端小智 Fundebug经授权转载,版权归原 ...

  5. 浅谈C#中的for循环与foreach循环

    for循环和foreach循环其实可以算得上是从属关系的,即foreach循环是可以转化成for循环,但是for循环不一定能转换成foreach循环. 下面简单介绍一下两种循环: 1.for循环 代码 ...

  6. arcgis api 3.x for js 入门开发系列十六迁徙流动图

    前言 关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 3.x for js:esri 官网 api,里面详细的介绍 arcgis api 3.x 各个类 ...

  7. June. 27th 2018, Week 26th. Wednesday

    To be great, truly great, you have to be the kind of person who makes the others around you great. 要 ...

  8. 写一函数,用来求表达式1+2+3+.....+n的值,并编写主函数

    Description 写一函数,用来求表达式1+2+3+.....+n的值,并编写主函数.n由键盘输入. Input 输入一个整数 Output 输出表达式的值 Sample Input 5 Sam ...

  9. WEB框架-Django框架学习(二)- 模型层

    今日份整理为模型层 1.ORM简介 MVC或者MVC框架中包括一个重要的部分,就是ORM,它实现了数据模型与数据库的解耦,即数据模型的设计不需要依赖于特定的数据库,通过简单的配置就可以轻松更换数据库, ...

  10. toast提示信息获取

    toast获取的前提条件 1.desired_caps["automationName"]="UiAutomator2"2.要求安装jdk1.8 64位及以上. ...