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 ...
随机推荐
- DS控件库 DS按钮多种样式
在DS控件库(DSControls)中,DS按钮的功能非常多,通过设置不同的属性值来使按钮呈现不同的效果.DS按钮的常用属性如下: 使用不同的属性调出不同的外观样式示例
- [TCP/IP] 网络层-ARP协议
ARP协议可以将网络层地址到任意物理地址转换,从IP地址到MAC地址转换 MAC地址:物理地址,网卡厂家要确保MAC地址全球唯一,48位2进制,显示是12位16进制 1.查看我自己的ip,我自己的的i ...
- Java基础差,需要怎么补
本文首发于本博客 猫叔的博客,转载请申明出处 感谢sugar的提问:Java基础差,需要怎么补? 欢迎关注公众号:Java猫说 我整体的总结了一下,大致分为以下的几个点说一下: 1.善于使用搜索引擎 ...
- 代码托管-gerrit-介绍与环境搭建
什么是gerrit? 转载自 https://blog.csdn.net/tanshizhen119/article/details/79874127 gerrit是谷歌开源的一个git服务端. 主要 ...
- 委托的多线程方法BeginInvoke
同步方法和异步方法: 同步方法调用在程序继续执行之前需要等待同步方法执行完毕返回结果.(比如烧水泡茶,需要等水烧开了才能继续泡茶) 异步方法则在被调用之后立即返回以便程序在被调用方法完成其任务的同时执 ...
- JAVA设计模式——简单工厂
工厂模式分为三种:简单工厂模式,工厂方法模式,抽象工厂模式.我看有的书上和有的文章里是分为两种,没有简单工厂. 工厂模式主要的作用是:一个对象在实例化的时候可以选择多个类,在实例化的时候根据一些业务规 ...
- 程序员50题(JS版本)(九)
程序41:八进制转换为十进制 var num1=425; var num2=0; num1=num1.toString(); for(var i=num1.length-1,root=1;i>= ...
- Ajax常见面试题
1,什么是ajax? 为什么要使用ajax? 1.ajax是"asynchornous javascript and xml "的缩写,指一种创建交互式网页应用的网页开发技术. 2 ...
- javascript排序算法-归并排序
归并排序 概念:归并排序是一种分治算法.其思想是将原始数组切分成较小的数组,直到每个小数组只有一个位置,接着将小数组归并成较大的数组,直到最后只有一个排序完毕的大数组. 时间复杂度: O(nlogn) ...
- iis读取不到本地证书问题
导入证书时,通过mmc命令打开控制台->添加管理单元或删除单元->选择本地计算机账号->然后导入证书,解决 ssl证书无法与www.xxx通信. 证书导入后,不能正常读取.有两个问题 ...