What Kind of Friends Are You? ZOJ 3960
比赛的时候用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的更多相关文章
- 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 ...
- ZOJ 3960 What Kind of Friends Are You? 【状态标记】
题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3960 题意 首先给出 一系列名字 需要辨别的名字,然后给出Q个问 ...
- 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 ...
- HZNU Training 4 for Zhejiang Provincial Collegiate Programming Contest 2019
今日这场比赛我们准备的题比较全面,二分+数论+最短路+计算几何+dp+思维+签到题等.有较难的防AK题,也有简单的签到题.为大家准备了一份题解和AC代码. A - Meeting with Alien ...
- ZOJ People Counting
第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ 3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...
- ZOJ 3686 A Simple Tree Problem
A Simple Tree Problem Time Limit: 3 Seconds Memory Limit: 65536 KB Given a rooted tree, each no ...
随机推荐
- 第66章 视频 - Identity Server 4 中文文档(v1.0.0)
第66章 视频 66.1 2019 January [NDC] - 使用ASP.NET Core 2.2和3.0保护Web应用程序和API 1月[NDC] - 为基于OpenID Connect / ...
- 使用C#开发windows服务定时发消息到钉钉群_群组简单消息
前言:本提醒服务,是由C#语言开发的,主要由windows服务项目和winform项目组成,运行服务可实现功能:向钉钉自定义机器人群组里,定时,定次,推送多个自定义消息内容,并实现主要功能的日志记录. ...
- Elasticsearch.Net、Nest批量插入BulkAll
demo地址:BulkAll 批量导入 实现目标:想要使用ElasticSearch的 .Net Api客户端NEST批量导入数据,并发异步高效的批量导入 NEST提供了BulkAll 不废话,上代码 ...
- SqlSugar ORM 入门篇2 【查询】 让我们实现零SQL
SqlSugar在查询的功能是非常强大的,多表查询.分页查询 . 一对一查询.二级缓存.一对多查.WhenCase等复杂函数.Mapper功能.和拉姆达自定义扩展等,用好了是可以做到真正零SQL的一款 ...
- oracle学习笔记(二) 基本数据类型
常用的数据类型 int number number(4,1) 999.1 四个数字,小数位一位 decimal date 日期 格式如下: 注意:日期类型的字段格式,可以通过以下三种方式: 1. da ...
- 学习day03
1.结构标记 ***** 做布局 1.<header>元素 <header></header> ==> <div id=&quo ...
- 小米5.0以上系统如何没ROOT激活xposed框架的经验
在较多企业的引流或者业务操作中,大多数需要使用安卓的黑高科技术xposed框架,这段时间,我们企业购买了一批新的小米5.0以上系统,大多数都是基于7.0以上版本,大多数不能够获取Root的su超级权限 ...
- MySQL系统变量sql_safe_updates总结
MySQL系统变量sql_safe_updates总结 在MySQL中,系统变量sql_safe_updates是个非常有意思的系统变量,在Oracle和SQL Server中都没有见过这样的参数 ...
- MVC 伪静态路由、MVC路由配置,实现伪静态。
前段时间,研究了一下mvc路由配置伪静态,在网上扒了很多最后还是行不通,所以我现在把这些心得整理出来,供大家分享: 1.mvc中默认路由配置是:http://localhost:24409/Home/ ...
- Python 之网络式编程
一 客户端/服务器架构 即C/S架构,包括 1.硬件C/S架构(打印机) 2.软件B/S架构(web服务) C/S架构与Socket的关系: 我们学习Socket就是为了完成C/S的开发 二 OSI七 ...