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 ...
随机推荐
- C# 2进制、8进制、10进制、16进制...各种进制间的转换(三) 数值运算和位运算
一.数值运算 各进制的数值计算很简单,把各进制数转换成 十进制数进行计算,然后再转换成原类型即可. 举例 :二进制之间的加法 /// <summary> /// 二进制之间的加法 /// ...
- Java开发笔记(八十一)如何使用系统自带的注解
之前介绍继承的时候,提到对于子类而言,父类的普通方法可以重写也可以不重写,但是父类的抽象方法是必须重写的,如果不重写,编译器就直接在子类名称那里显示红叉报错.例如,以前演示抽象类用法之时,曾经把Chi ...
- 倒计时5S秒自动关闭弹窗
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Android Studio教程11-RecycleView的使用
目录 1. RecyclerView 1.1. Add support library 1.2. 将RecyclerView添加到布局 1.3. 主actiivty中如何调用recycleview对象 ...
- 网站注册与登录使用 bcrypt与 passport 双重验证 解释
网站在登录前,需要进行注册收集用户基本信息,bcrypt 提供密码加密验证的方法,但是使用不正确,会给初学者带来各种问题. bcrypt 的安装: npm i bcrypt 经过测试,经常安装不成功, ...
- Visual Studio插件开发基础
Visual Studio插件主要有两种:Add-in 和 VSX(Visual Studio eXtensibility) 两者区别可参考这篇文章:Visual Studio Extensions ...
- MyDAL - .QueryOneAsync() 使用
索引: 目录索引 一.API 列表 .QueryOneAsync() .QueryOneAsync<M>() 如: .QueryOneAsync<Agent>() , 用于 单 ...
- postman的简单使用
Postman简单的使用 什么是Postman 在程序开发中用于调试网络程序或者跟踪网页请求.可以对网页进行简单的基本信息调试.Postman最早是作用chrome浏览器插件存在的,但是2018年初 ...
- The xp_cmdshell proxy account information cannot be retrieved or is invalid. Verify that the '##xp_cmdshell_proxy_account##' credential exists and contains valid information.
In one of our recent migrations, we got the following error when the client tried to fire xp_cmdshel ...
- python学习笔记5_异常
python学习笔记5_异常 1.什么事异常 Python使用异常对象(exception object) 来表示异常情况.遇到错误会发生异常. 如果异常对象未被处理或被捕捉,程序就会用所谓的回溯(t ...