HDU 1707 简单模拟 Spring-outing Decision

Spring-outing Decision

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 676    Accepted Submission(s): 220

Problem Description
Now
is spring ! The sunshine is warm , the flowers is coming out . How
lovely it is! So my classmates and I want to go out for a spring-outing.

But
we all select courses ourselves. We don't have classes at the same
time.Now our monitor has a big trouble in arranging the time of the
spring-outing.

Can you help him?

I will give you our courses information and the time of the spring-outing.You just need to tell me that who can't go with us.

 
Input
The first line contains an integer CA which indicates the number of test cases.
Then CA cases follow.
Each case contains two parts,the students' courses information and the query.

In
the first part ,first there is an integer N(N<200) which means the
number of the student,and then comes the N students’ courses
information.
A student's courses information is in this format:

line1: name K
line2: day1 b1 e1
.....
lineK+1: dayK bK eK

The
first line of a student's courses infomation contains his name(less
than 20 characters and in lowercase) and the number(K,K<1000) of his
courses . Then next K lines describe his courses. Each Line contain
three integers indicate the day of a week( 1 <= day <= 7 means
Monday to Sunday ), the begin time and the end time of the course.
To
make the problem easier,the begin time and the end time will be in the
range from 1 to 11 .(Because in HDU,there is 11 classes one day).

In the query part , first there is an integer Q which means the query number,and then Q lines follow.
A
query contains three integers which means the day ,the begin time and
the end time of the spring-outing.And the time is described as the
courses.
Notice,everyone may have more than one course at the same time for some special reasons.

 
Output
For each query , just print the names of the students who can't go out for a spring-outing in a line in lexicographic order.
Please separate two names with a blank.
If all of the students have time to go , just print "None" in a line.
 
Sample Input
1
3
linle 3
1 1 2
2 3 4
3 8 10
laili 1
4 1 4
xhd 2
1 2 4
4 5 6
3
1 2 2
4 4 5
5 1 2
 
Sample Output
linle xhd
laili xhd
None
 
Author
linle
 
Source
 
 
 
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int Map[][][];
char str[][];
char tstr[][];
bool ans[];
int cnt[];
int main(){
int tt;
scanf("%d",&tt);
while(tt--){
memset(Map,,sizeof(Map));
memset(str,,sizeof(str));
int n;
scanf("%d",&n);
for(int i=;i<=n;i++){
getchar();
int k;
scanf("%s %d",str[i],&k);
for(int j=;j<=k;j++){
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
for(int z=b;z<=c;z++){
Map[i][a][z]=;
}
}
}
int q;
scanf("%d",&q); for(int i=;i<=q;i++){
memset(ans,false,sizeof(ans));
memset(cnt,,sizeof(cnt));
int t,t1,t2;
scanf("%d%d%d",&t,&t1,&t2);
for(int j=;j<=n;j++){
for(int k=t1;k<=t2;k++){
if(Map[j][t][k])
ans[j]=true;
}
}
int Count=;
for(int j=;j<=n;j++){
if(ans[j])
cnt[++Count]=j;
} if(Count==)
printf("None\n");
else{
for(int ii=;ii<Count;ii++){
for(int jj=ii+;jj<=Count;jj++){
if(strcmp(str[cnt[ii]],str[cnt[jj]])>){///此步应该特别注意
int temp1=cnt[ii];
cnt[ii]=cnt[jj];
cnt[jj]=temp1;
}
}
}
for(int qq=;qq<=Count;qq++){
printf("%s%c",str[cnt[qq]],qq==Count?'\n':' ');
}
}
}
}
return ;
}
上一篇:申请https证书需要注意的4大问题


下一篇:C++是跨平台的语言