题目:

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. PhpStorm创建Drupal模块项目开发教程(2)

    通常支持Drupal HOOK的文件为.module.首先我们需要在这里对它进行声明,以便索引,并且在代码完成中使用Ctrl+Space(空格)完成HOOK实现. Drupal HOOK调用,通常情况 ...

  2. thinkPHP 5.0.x 使用SQLite3 进行缓存设置 Cache

    1. 配置 thinkPHP cache [application/config.php] 把type设置为sqlite3(默认是小写,第一个字母不区分大小写) 把path换成db,并指定sqlite ...

  3. html标签快速转换思想方法

    function htmlencode(s){ var div = document.createElement('div'); div.appendChild(document.createText ...

  4. IE兼容性的注意点

    IE会将注释节点实现为元素,所以在IE中调用getElementsByTagName里面会包含注释节点,这个通常是不应该的 getElementById的参数在IE8及较低的版本不区分大小写 IE7及 ...

  5. 关于sql 的列转行

    select * from TbaleOne unpivot(qty ])) as up go select * from TableTwo unpivot(grate for subject in ...

  6. [转载]Back up all of your mysql databases nightly

    原文地址:http://www.linuxbrigade.com/back-up-all-of-your-mysql-databases-nightly/ Put the following into ...

  7. VirtualBox 共享文件夾

    説明:host為window10,guest為centos7 一.安装VBoxLinuxAdditions 1. 在guest上挂载virtualbox安装目录下的VBoxGuestAdditions ...

  8. 2.ReactNative Properties|States|Styles 笔记

    原文地址:http://reactnative.cn/docs/0.31/props.html#content 1. property: 如下代码所示 import React, { Componen ...

  9. shutdown的简单小应用

    关于shutdown的操作命令在此不做详细叙述 1.WIN+R ,输入cmd即打开cmd命令界面 2.输入shutdown /help,出现下图 这里介绍一个关于shutdown的小应用: 比如我们的 ...

  10. 我的git学习

    当遇到不想commit的,而status已经现实出来了,可以使用 git rm -r --cached "fine name or 文件夹" 出现   Git – fatal: U ...