CFGym

来源:互联网 发布:ps磨皮插件怎么安装mac 编辑:程序博客网 时间:2024/06/09 15:39

1.题目描述:

M. ACPC Headquarters : AASTMT (Stairway to Heaven)
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard 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.

Examples
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
2.题意概述:

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

3.解题思路:

很朴素的想法,先把队伍映射成标号,然后vis区间标记它的开始时间和结束时间,如果发生冲突则放入set里面,因为set本身就是按字典排序,因此最后直接输出就行。

4.AC代码:

#include <bits/stdc++.h>#define INF 0x7fffffff#define maxn 100100#define N 400#define eps 1e-6#define pi acos(-1.0)#define e 2.718281828459#define mod (int)1e9 + 7;using namespace std;typedef long long ll;map<string, int> mp;set<string> ans;int vis[maxn][N];char name[N], contest[N];int main(){#ifndef ONLINE_JUDGE  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout);  long _begin_time = clock();#endif  int t, n, v, sta, ed;  scanf("%d", &t);  while (t--)  {    mp.clear();    ans.clear();    memset(vis, 0, sizeof(vis));    scanf("%d", &n);    int cnt = 0;    for (int i = 0; i < n; i++)    {      scanf("%s%d%d%d", contest, &sta, &ed, &v);      for (int j = 0; j < v; j++)      {        scanf("%s", name);        if (!mp.count(string(name)))          mp[string(name)] = ++cnt;        int &m = mp[string(name)];        for (int k = sta; k <= ed; k++)        {          if (vis[m][k])            ans.insert(string(name));          vis[m][k] = 1;        }      }    }    printf("%d\n", ans.size());    for (set<string>::iterator it = ans.begin(); it != ans.end(); it++)      cout << (*it) << endl;  }#ifndef ONLINE_JUDGE  long _end_time = clock();  printf("time = %ld ms\n", _end_time - _begin_time);#endif  return 0;}

0 0
原创粉丝点击