hdu 1707(memset妙用)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1707

思路:memset妙用,把当天的上课时间标记为true..然后查询的时候进行遍历就行了。

View Code
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 #include<cstdlib>
 6 using namespace std;
 7 #define MAXN 222
 8 struct Person{
 9     bool time[11][14];
10     char name[22];
11 }Per[MAXN];
12 int n;
13 
14 int cmp(const void *a,const void *b){
15     return (strcmp((char *)a,(char *)b));
16 }
17 
18 int main(){
19     int _case;
20     scanf("%d",&_case);
21     while(_case--){
22         memset(Per,false,sizeof(Per));
23         int n,k,d,s,e;
24         scanf("%d",&n);
25         for(int i=1;i<=n;i++){
26             scanf("%s%d",Per[i].name,&k);
27             while(k--){
28                 scanf("%d%d%d",&d,&s,&e);
29                 memset(Per[i].time[d]+s,true,(e-s+1)*sizeof(Per[i].time[0][0]));
30             }
31         }
32         scanf("%d",&k);
33         while(k--){
34             scanf("%d%d%d",&d,&s,&e);
35             char str[MAXN][22];
36             int count=0;
37             for(int i=1;i<=n;i++){
38                 bool flag=true;
39                 for(int j=s;j<=e;j++){
40                     if(Per[i].time[d][j]){flag=false;break;}
41                 }
42                 if(!flag){strcpy(str[count++],Per[i].name);}
43             }
44             if(count==0){puts("None");continue;}
45             qsort(str,count,sizeof(str[0]),cmp);
46             for(int i=0;i<count-1;i++){
47                 printf("%s ",str[i]);
48             }
49             printf("%s\n",str[count-1]);
50         }
51     }
52     return 0;
53 }
54 
55 
56                 
57                 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值