题目:

Description

standard input/output

As most of you know, the Arab Academy for Science and Technology and Maritime Transport in Alexandria, Egypt, hosts the ACPC Headquarters in the Regional Informatics Center (RIC), and it has been supporting our region with all kinds of resources it can provide, whether it was hosting nationals, regionals, or providing support for national contests around the Arab Region by sending its employees and students to participate in preparing contest systems, coaching, problem setting, and whatever these nationals ask for. However, ACPC's volunteers' schedules can get very busy, therefore, some conflicts might occur between the nationals they are assigned to help with. As to resolve these conflicts, Noura suggested that the SCPC2015 students can come up with a program that detects the conflicts in the contests' schedule, and that is, detect for each volunteer whether they have been assigned to multiple contests running at the same time.

Given the requirements for each contest (contest name, start date, end date, number of required volunteers, volunteers' names), print a list of volunteers' names that have conflicts in their schedules, sorted in alphabetical order.

Input

The first line of input contains an integer T (1 ≤ T ≤ 64), the number of test cases.

The first line of each test case contains an integer N (1 ≤ N ≤ 100), the number of contests.

Each of the following N lines contains one contest's data: Contest name C, start date S, end date E, number of required volunteers V, followed by V distinct volunteers' names.

Names consist of lowercase Latin letters, and their length doesn't exceed 10 letters.

You may assume that (1 ≤ S ≤ E ≤ 365) and (1 ≤ V ≤ 100).

Output

For each test case, print the number of volunteers that have conflicts in their schedules, followed by the names of the volunteers in alphabetical order, each on a single line.

Sample Input

Input
2
2
lcpc 3 7 4 fegla compo fouad nicole
scpc 5 11 3 fegla fouad nicole
2
jcpc 8 10 2 fegla hossam
scpc 10 15 3 fegla fouad nicole
Output
3
fegla
fouad
nicole
1
fegla

题意:给出n个比赛开始时间,结束时间,志愿者人数及名单,输出参加的比赛时间有重合的志愿者名字,按字母序输出

分析:第一交的时候TLE了,第一次我是先判断哪些比赛时间重合了,然后再对时间重合的比赛需要的志愿者进行判断是否重合了。再次看题后发现,其实没必要先判断比赛时间是否重合,因为题目只要求有比赛时间重合的志愿者就输出,可以直接判断每个志愿者是否有比赛时间重合即可。

代码:

 #include<iostream>
#include<stdio.h>
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
using namespace std;
map<string,int>mp;
vector<pair<int,int> >v[];
vector<string>ans;
string s[];
int cmp1(string s,string t){return s<t;}
int cmp(pair<int,int>a,pair<int,int>b)
{
if(a.first==b.first)
return a.second<b.second;
return a.first<b.first;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
mp.clear();
ans.clear();
int n,st,en,vol;
int cnt=;
string na;
scanf("%d",&n);
for(int i=;i<n;i++)
{
cin>>na>>st>>en>>vol;
for(int j=;j<vol;j++)
{
cin>>na;
if(mp[na])
v[mp[na]].push_back(make_pair(st,en));
else
{
mp[na]=++cnt;
s[cnt]=na;
v[cnt].clear();
v[cnt].push_back(make_pair(st,en));
}
}
}
//cout<<cnt<<endl;
for(int i=;i<=cnt;i++)
{
//cout<<v[i].size()<<endl;
if(v[i].size()==)
continue;
sort(v[i].begin(),v[i].end(),cmp);
for(int j=;j<v[i].size()-;j++)
{
if(v[i][j].second>=v[i][j+].first)
{
ans.push_back(s[i]);
break;
}
}
}
sort(ans.begin(),ans.end(),cmp1);
printf("%d\n",ans.size());
for(int i=;i<ans.size();i++)
cout<<ans[i]<<endl;
}
return ;
}

cf Gym 101086M ACPC Headquarters : AASTMT (Stairway to Heaven)的更多相关文章

  1. CF Gym 102028G Shortest Paths on Random Forests

    CF Gym 102028G Shortest Paths on Random Forests 抄题解×1 蒯板子真jir舒服. 构造生成函数,\(F(n)\)表示\(n\)个点的森林数量(本题都用E ...

  2. CF gym 101933 K King's Colors —— 二项式反演

    题目:http://codeforces.com/gym/101933/problem/K 其实每个点的颜色只要和父亲不一样即可: 所以至多 i 种颜色就是 \( i * (i-1)^{n-1} \) ...

  3. CF Gym 100685A Ariel

    传送门 A. Ariel time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  4. CF Gym 100685E Epic Fail of a Genie

    传送门 E. Epic Fail of a Genie time limit per test 0.5 seconds memory limit per test 64 megabytes input ...

  5. CF GYM 100703A Tea-drinking

    题意:龙要制作n个茶,每个茶的配方是一个字符串,两个字符串之间有一个差值,这个差值为两个字符串每个对应字母之间差的绝对值的最大值,求制作所有茶时获得的所有差值中的最大值. 解法:克鲁斯卡尔.将茶的配方 ...

  6. CF GYM 100703B Energy Saving

    题意:王子每月买m个灯泡给n个房间换灯泡,如果当前有的灯泡数够列表的第一个房间换的就全换,直到灯泡不够为止,给出q个查询,查询x月已经换好几个房子,手里还剩多少灯泡. 解法:水题……小模拟. 代码: ...

  7. CF GYM 100703F Game of words

    题意:两个人玩n个游戏,给出每人玩每个游戏的时间,两个人需要在n个游戏中挑m个轮流玩,求最短时间. 解法:dp.(这场dp真多啊……话说也可以用最小费用最大流做……然而并不会XD)dp[i][j][k ...

  8. CF GYM 100703G Game of numbers

    题意:给n个数,一开始基数为0,用这n个数依次对基数做加法或减法,使基数不超过k且不小于0,输出最远能运算到的数字个数,输出策略. 解法:dp.dp[i][j]表示做完第i个数字的运算后结果为j的可能 ...

  9. CF GYM 100703I Endeavor for perfection

    题意:有n个学习领域,每个领域有m个课程,学习第i个领域的第j个课程可以获得sij个技能点,在每个领域中选择一个课程,要求获得的n个技能点的最大值减最小值最小,输出符合要求的策略. 解法:尺取法.将课 ...

随机推荐

  1. 关于strlen误用的一点记录

    今天帮一个朋友查一个错误,是运行时报vector iterator incompatible,一般这种问题是向量和迭代器的类型不兼容,或者是进行迭代器判等时前后向量的结构发生变化,如erase操作之后 ...

  2. 怎么通过 Mysql 实现数据同步呢?

    怎么使 mysql 数据同步先假设有主机 A 和 B ( linux 系统),主机 A 的 IP 分别是 1.2.3.4 (当然,也可以是动态的),主机 B 的 IP 是 5.6.7.8 .两个主机都 ...

  3. 设置myeclipse新建jsp文件默认编码为UTF-8

    有三个地方需要改编码设置: 1. window-->preference-->general-->contenttype 然后在content types中展开每一个子项,并在Def ...

  4. JAVA异常处理机制的简单原理和应用

  5. 【转】Git图形化界面客户端大汇总

    原文网址:http://my.oschina.net/amstrong/blog/159114 目录[-] 一.TortoiseGit - The coolest Interface to Git V ...

  6. linux下打开、关闭tomcat,实时查看tomcat运行日志

    启动:一般是执行sh tomcat/bin/startup.sh 停止:一般是执行sh tomcat/bin/shutdown.sh脚本命令 查看:执行ps -ef |grep tomcat 输出如下 ...

  7. linux批量查找文件内容

    find ./ -name "*.php" | xargs grep '要查找的内容' 如果需要查找的内容包含特殊符号,比如$等等,grep要加参数 find ./ -name & ...

  8. div css 自适应

    怎样实现响应式布局? 对于这个问题,我们可以通过CSS3中的Media Query来实现,即媒介查询.媒体查询让CSS可以更精确作用于不同的媒体类型和同一媒体的不同条件.媒体查询的大部分媒体特性都接受 ...

  9. js 、jsdoc生成33

    ============== js 点击事件后没方法名,调用有方法名 document.getElementById('lind').onclick=abc;//传统的id选择器 中没有# 哦 fun ...

  10. 【STL】优先队列priority_queue详解+OpenJudge-4980拯救行动

    一.关于优先队列 队列(queue)这种东西广大OIer应该都不陌生,或者说,队列都不会你还学个卵啊(╯‵□′)╯︵┻━┻咳咳,通俗讲,队列是一种只允许从前端(队头)删除元素.从后端(队尾)插入元素的 ...