CFGym
来源:互联网 发布:ps磨皮插件怎么安装mac 编辑:程序博客网 时间:2024/06/09 15:39
1.题目描述:
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.
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).
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.
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
3feglafouadnicole1fegla
给出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;}
- CFGym
- CFGym
- CFGym
- CFGym
- CFGym
- CFgym:Castle(KMP)
- CFGym 101490D DP
- CFgym 100803D -Space Golf
- CFgym:Database(字符串处理)
- CFgym:Palindromization(字符串Hash)
- CFgym:Digits Permutation(DFS)
- CFgym:Good morning!(dfs)
- CFgym:Hidden Anagrams(Hash)
- CFGym 101002C 状压DP
- CFgym 100851B-Binary vs Decimal
- CFgym:Bonuses and Teleports(贪心)
- CFgym:Of Zorcs and Axes(贪心)
- CFgym:Treasure Island(搜索 & 思维)
- CSS实现元素居中-01
- 什么是跨域?怎么解决跨域问题?
- 使用com.android.support:design 中的 “CollapsingToolbarLayout”,页面崩溃
- 信息: Initializing Spring FrameworkServlet 'spring'
- 复习
- CFGym
- 集合迭代时候操作解决方案-ArrayList-Iterator-CopyOnWriteArrayList
- nginx FastCGI 安装配置
- TX1上使用265实时硬编码
- 第八届省赛ACM赛后总结
- svn-commit遇上aborting commit: remains in conflict 解决办法
- Mybatis入门笔记--终端显示sql语句
- 华为交换机S5700配置VLAN和VLANif
- Functional Programming in R