题目:

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
22lcpc 3 7 4 fegla compo fouad nicolescpc 5 11 3 fegla fouad nicole2jcpc 8 10 2 fegla hossamscpc 10 15 3 fegla fouad nicole

Output
3feglafouadnicole1fegla

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

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

代码:

 1 #include<iostream>
 2 #include<stdio.h>
 3 #include<vector>
 4 #include<map>
 5 #include<algorithm>
 6 #include<set>
 7 #include<string>
 8 #include<string.h>
 9 using namespace std;
10 map<string,int>mp;
11 vector<pair<int,int> >v[11000];
12 vector<string>ans;
13 string s[11000];
14 int cmp1(string s,string t){return s<t;}
15 int cmp(pair<int,int>a,pair<int,int>b)
16 {
17     if(a.first==b.first)
18         return a.second<b.second;
19     return a.first<b.first;
20 }
21 int main()
22 {
23     int t;
24     scanf("%d",&t);
25     while(t--)
26     {
27         mp.clear();
28         ans.clear();
29         int n,st,en,vol;
30         int cnt=0;
31         string na;
32         scanf("%d",&n);
33         for(int i=0;i<n;i++)
34         {
35             cin>>na>>st>>en>>vol;
36             for(int j=0;j<vol;j++)
37             {
38                  cin>>na;
39                  if(mp[na])
40                     v[mp[na]].push_back(make_pair(st,en));
41                  else
42                  {
43                      mp[na]=++cnt;
44                      s[cnt]=na;
45                      v[cnt].clear();
46                      v[cnt].push_back(make_pair(st,en));
47                  }
48             }
49         }
50         //cout<<cnt<<endl;
51         for(int i=1;i<=cnt;i++)
52         {
53             //cout<<v[i].size()<<endl;
54             if(v[i].size()==1)
55                 continue;
56             sort(v[i].begin(),v[i].end(),cmp);
57             for(int j=0;j<v[i].size()-1;j++)
58             {
59                 if(v[i][j].second>=v[i][j+1].first)
60                 {
61                     ans.push_back(s[i]);
62                     break;
63                 }
64             }
65         }
66         sort(ans.begin(),ans.end(),cmp1);
67         printf("%d\n",ans.size());
68         for(int i=0;i<ans.size();i++)
69             cout<<ans[i]<<endl;
70     }
71     return 0;
72 }

转载于:https://www.cnblogs.com/tristatl/p/5873642.html

cf Gym 101086M ACPC Headquarters : AASTMT (Stairway to Heaven)相关推荐

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

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

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

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

  3. ACPC Headquarters : AASTMT (Stairway to Heaven)

              连接:传送门 As most of you know, the Arab Academy for Science and Technology and Maritime Trans ...

  4. CF Gym 100227 I题 题解

    这场Gym全名是这个:2013-2014 CT S01E01: Extended 2000 ACM-ICPC East Central North America Regional Contest ( ...

  5. Caravan Robbers CF Gym - 100134C

    https://cn.vjudge.net/problem/Gym-100134C http://codeforces.com/gym/100134/attachments 答案就是最小的min(bi ...

  6. CF Gym 100187E Two Labyrinths (迷宫问题)

    题意:问两个迷宫是否存在公共最短路. 题解:两个反向bfs建立层次图,一遍正向bfs寻找公共最短路 #include<cstdio> #include<cstring> #in ...

  7. CF Gym 101630 B Box

    题目的意思大概就是给一个长方体的长宽高,问他能不能用一个w*h的纸剪出来,就是说展开图的长宽能不能比给定的小. 题目给了11中展开图的拓扑结构,我觉得这个很关键,要是题目没有给这个我可能想不到那么全面 ...

  8. CF GYM 100703G Game of numbers

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

  9. 【CF gym 103260】40th Petrozavodsk Programming Camp, Day 5,2021.2.3 水题2题

    M.Discrete Logarithm is a Joke 题意: 思路: 不难想到an=g^{an+1},因为样例给了 a[1000000]的值,所以反着推就行了. 记得开int128,longl ...

最新文章

  1. 《Swift开发实战》——第2章,第2.4节函数和闭包
  2. 学习笔记之06-点语法
  3. 1.6 多项式回归-机器学习笔记-斯坦福吴恩达教授
  4. tomcat启动时提示Failed to initialize end point associated with ProtocolHandler [http-apr-8080]
  5. Web前端技术分享:Javascript中的内置对象数组讲解
  6. Java知识整理——JDBC
  7. 禅道项目管理_禅道项目管理软件 v12.5.1 开源版
  8. 1-3 交换变量(算法竞赛入门经典)
  9. Guava - 拯救垃圾代码,写出优雅高效,效率提升N倍
  10. JUC组件扩展(二)-JAVA并行框架Fork/Join(四):监控Fork/Join池
  11. (96)Verilog HDL:点灯设计
  12. python hello world重复_查找数组中重复的数字-python版
  13. 小程序nginx做反向代理_NGINX作为节点或Angular应用程序的反向代理
  14. java栈属于哪个代,Java 代码执行原理
  15. 未来-IOT-Aliyun:阿里云 IOT - 开发者社区
  16. java 区间api_Java 常用API(一)
  17. CitrixVDI新版动手实验手册
  18. itop 导入AD用户
  19. 简单易上手的微信电子名片的制作方法!
  20. ssh安装与配置(详解版)

热门文章

  1. 计算机管理器用户怎么打开文件,电脑文件管理器怎么打开文件夹 文件管理器打开想要的文件夹方法-电脑教程...
  2. 让独居的父母,时刻受到保护,老人远程无线监护解决方案
  3. js赋值改变后,原数据也发生改变
  4. 如何提升百度竞价推广的转化率?
  5. 中首清算|大数据助力灵活用工保驾护航
  6. (二)Java线程与系统线程,生命周期
  7. free spaces
  8. 一度智信:拼多多商家开直通车大忌
  9. word或wps中如何把visio或公式等转换为图片
  10. 九。温暖地待人,你才会得到意想不到的惊喜结果。