连接:传送门

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.

Example

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

题意:

将有时间冲突的志愿者找出来,按字典序输出

思路:

将所有志愿者存放到map中,将多次出现在比赛的志愿者的开始和结束时间存放到vector容器中,再用set容器将有冲突的志愿者存放起来,最后输出set容器中的元素,c++的STL真是强大

map:连接传送门

set:连接传送门

vector:连接传送门

代码如下:

#include<iostream>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string.h>
#include<cmath>
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
map<string,int>mymap;
set<string>vl;
vector<pair<int,int> >v[11000];
string s[11000];
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,n,st,et,vn;string str;scanf("%d",&t);set<string>::iterator it;while(t--){vl.clear();scanf("%d",&n);mymap.clear();int ans=0;for(int i=0;i<n;i++){cin>>str>>st>>et>>vn;for(int j=0;j<vn;j++){cin>>str;if(mymap[str])//之前存在,将时间记录下来v[mymap[str]].push_back(make_pair(st,et));else{mymap[str]=++ans;//标号s[ans]=str;v[ans].clear();v[ans].push_back(make_pair(st,et));}}}for(int i=1;i<=ans;i++){if(v[i].size()==1)//没有重复的continue;sort(v[i].begin(),v[i].end(),cmp);for(int j=0;j<v[i].size()-1;j++){if(v[i][j].second>=v[i][j+1].first)//判断时间是否冲突vl.insert(s[i]);}}cout<<vl.size()<<endl;for(it=vl.begin();it!=vl.end();++it)cout<<*it<<endl;}return 0;
}

ACPC Headquarters : AASTMT (Stairway to Heaven)相关推荐

  1. Codeforces Gym 101086 M ACPC Headquarters : AASTMT (Stairway to Heaven)

    Codeforces Gym 101086 M ACPC Headquarters : AASTMT (Stairway to Heaven) 题目来源: Codeforces 题意: 给出一些比赛, ...

  2. CFGym - 101086M. ACPC Headquarters : AASTMT (Stairway to Heaven) - 字符串处理

    1.题目描述: M. ACPC Headquarters : AASTMT (Stairway to Heaven) time limit per test 2 seconds memory limi ...

  3. cf Gym 101086M ACPC Headquarters : AASTMT (Stairway to Heaven)

    题目: Description standard input/output As most of you know, the Arab Academy for Science and Technolo ...

  4. 2015 ACM Syrian Collegiate Programming Contest

    A. My Friend of Misery 计算出答案的上下界即可. 时间复杂度$O(n)$. #include<bits/stdc++.h> using namespace std; ...

  5. GYM 2015 ACM Syrian Collegiate Programming Contest

    题目链接:http://codeforces.com/gym/101086 A My Friend of Misery B Brother Louie C Everything D Secure bu ...

  6. linux 创建目录 默认权限,如何设置UNIX/Linux中新创建目录或文件的默认权限

    在unix或者linux中,每创建一个文件或者目录时,这个文件或者目录都具有一个默认的权限,比如目录755,文件644,那么这些默认权限是怎么控制的呢? 答案是"umask"权限掩 ...

  7. python使用教程pandas-Python 数据处理库 pandas 入门教程基本操作

    pandas是一个Python语言的软件包,在我们使用Python语言进行机器学习编程的时候,这是一个非常常用的基础编程库.本文是对它的一个入门教程. pandas提供了快速,灵活和富有表现力的数据结 ...

  8. Java入门超简单程序Song List

    题目 The goal of this project is to write an application for maintaining a list of songs. Each song ha ...

  9. 写出整洁的高效的js代码

    Variables:变量 使用有意义的可发音的变量名 Bad: var yyyymmdstr = moment().format('YYYY/MM/DD'); Good: var yearMonthD ...

最新文章

  1. win32 api setwindowlong 第2个参数_第 6 篇:分页接口
  2. [转] 用Firebug调试JavaScript
  3. BZOJ4855 : [Jsoi2016]轻重路径
  4. uniapp光标自动定义到文本框_word技巧自动生成毕业论文目录
  5. ubuntu学习笔记之安装oracle客户端
  6. RportViewer(20121023) 参数引起的异常
  7. atitit 技术选型之道. attilax著 艾龙著 1. 标准 2 1.1. 符合趋势度 2 1.2. 简单易用 2 1.3. 文档丰富度 2 1.4. 下载便利性 2 1.5. 性能 2 1.
  8. 《嵌入式 – GD32开发实战指南》第4章 GD32启动流程详解(Keil版)
  9. Cameralink协议
  10. 心海软件学生测试系统,心海软件心理管理系统
  11. 佳能软件不用光盘安装升级包的方法
  12. 学大伟业2018-2019学年第二学期《自主招生集训课程》
  13. 一些不错的开源代码网站
  14. 第一遍Java学习笔记
  15. Java中print()\println()\printf()的区别及用法
  16. 腾讯地图初始化以及解析和逆解析
  17. 基于 React hooks + Typescript + Cesium 实现地下模式预览
  18. 效果超好的自制美白面膜大汇总 - 生活至上,美容至尚!
  19. 解决微信小程序 wx.request 方法不支持 Promise 并发数问题
  20. SimpleFOC(四)—— 闭环控制

热门文章

  1. 【Chrome-Charset】Chrome设置字符集
  2. MAC获取公钥的步骤
  3. 字符串与数字相互转化
  4. switch的使用及注意事项
  5. HDU2072(单词数)
  6. Git之版本回退与前进
  7. LG发布新专利,将为VR头显集成眼球追踪技术
  8. CleanMyMac XMac苹果电脑专属系统优化工具
  9. 拍摄独特人像的技巧(下)
  10. (OpenCV+Python)--目标跟踪,卡尔曼滤波+鼠标轨迹跟踪