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.
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
3 fegla fouad nicole 1 fegla
题意,就是让你求被重复挑选的制原则的名单,用容器很简单就可以ac的,而且1m就足够
用到了map和vector
ac代码
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <set>
#define ll long long
using namespace std;
int t,n;
struct node{
char c[25];
int s,e,v;
char vname[105][25];
}nn[110];
bool cmp(node a1,node a2){
if(a1.s == a2.s)
return a1.e < a2.e;
return a1.s < a2.s;
}
map<string, vector<pair<int, int> > > mmp;
set<string> st;
int main(){
scanf("%d",&t);
while(t--){
scanf("%d",&n);
st.clear();
mmp.clear();
for(int i=1;i<=n;i++){
scanf("%s%d%d%d",nn[i].c,&nn[i].s,&nn[i].e,&nn[i].v);
for(int j=1;j<=nn[i].v;j++){
scanf("%s",nn[i].vname[j]);
for(int k=0;k<mmp[nn[i].vname[j]].size();k++){
if(mmp[nn[i].vname[j]][k].first <= nn[i].s && nn[i].s <=mmp[nn[i].vname[j]][k].second ){
st.insert(nn[i].vname[j]);
}
else if(mmp[nn[i].vname[j]][k].first <= nn[i].e && nn[i].e <=mmp[nn[i].vname[j]][k].second)
st.insert(nn[i].vname[j]);
else if(mmp[nn[i].vname[j]][k].first >= nn[i].s && nn[i].e >=mmp[nn[i].vname[j]][k].second)
st.insert(nn[i].vname[j]);
}
mmp[nn[i].vname[j]].push_back(make_pair(nn[i].s,nn[i].e));
}
}
//cout<< st.size()<<endl;
printf("%d\n",st.size());
set<string>::iterator it;
for(it=st.begin();it!=st.end();it++){
//cout << *it<<endl;
string s=*it;
printf("%s\n",s.c_str());
}
}
return 0;
}