题目:

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. python_函数

    一.map 遍历序列,对序列中每个元素进行操作,最终获取新的序列 li = [11,22,33,44] new_list = map(lambda a: a + 100,li) print(new_l ...

  2. 我的Android第三章

    先看效果图. 点击之后出变成 按钮内容改变了,并且弹出一个小提示 下面我们就来看看如何实现这个小案例 1)先打开string.xml文件,把要定义的字符串资源放置在里面 2)然后我们要画页面,基本An ...

  3. NPY and girls-HDU5145莫队算法

    Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description ...

  4. 某预约系统分析 > 某区公共自行车租车卡在线预约,关于如何提高成功概率

    概诉 网上提交预约申请单,线下面交完成实体卡的交付和办理. 本文主要从技术角度分析预约页面,仅供初学者技术交流使用. 表单输入和校验 系统通过2步的确认点击到达信息输入页面. 地址:/bjggzxc/ ...

  5. jquery 获取元素背景图片backgroungImage的url

    $("#").css("backgroundImage").replace('url(','').replace(')','');

  6. JAVA可阻塞队列-ArrayBlockingQueue子类BlockingQueue的应用,使用它来实现子线程打印10次,主线程打印100次,如此反复

    /** * 使用BlockingQueue实现主子线程互相打印 * @author duwenlei * */ public class BlockingQueueTest { public stat ...

  7. 对json数据的遍历

    json格式变化多样,可嵌套好几层,这里只记录了一些遍历方法,具体数据格式具体分析~ "data1": { "key1": [ {"name" ...

  8. RMQ

    1.概念: RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A ...

  9. word域3

    WORD是文字处理软件,我们在日常处理一些文字时经常遇到一些问题,如:各种公式的录入,尽管Word都提供了"公式编辑器",但其插入的却是"对象",有时排版会感觉 ...

  10. 求System.arraycopy的用法

    public class Shuzufuzhi { public static void main(String args[]) {  int myArray[]={1,2,3,4,5,6};  in ...