HDU-1707-Spring-outing Decision

Spring-outing Decision

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
#include<bits/stdc++.h>
using namespace std;
struct classes
{
    char a[50];
    int b;
    int c[1005],d[1005],e[1005];
    int f;
}q[205];
int cmp(classes x,classes y)
{
    if(strcmp(x.a,y.a)>0)
    return 0;
    else
    return 1;
}
int main()
{
    int n,a,t,flag,m,c,d,e;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            scanf("%s",q[i].a);
            scanf("%d",&q[i].b);
            for(int j=0;j<q[i].b;j++)
            {
                scanf("%d %d %d",&q[i].c[j],&q[i].d[j],&q[i].e[j]);
            }
        }
        scanf("%d",&m);
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                q[j].f=0;
            }
            flag=0;
            scanf("%d%d%d",&c,&d,&e);
            for(int j=0;j<n;j++)
            {
                for(int k=0;k<q[j].b;k++)
                {
                    if(c==q[j].c[k])
                    {
                        if((d>=q[j].d[k]&&d<=q[j].e[k])||(e>=q[j].d[k]&&e<=q[j].e[k])||(d<=q[j].d[k]&&e>=q[j].e[k])||(e==q[j].d[k])||(d==q[j].e[k]))
                        {
                            flag=1;
                            q[j].f=1;
                            break;
                        }
                    }
                }
            }
            if(flag==0)
            {
                printf("None\n");
            }
            else
            {
                sort(q,q+n,cmp);
                for(int l=0;l<n;l++)
                {
                    if(q[l].f==1)
                    {
                        q[l].f=0;
                        printf("%s",q[l].a);
                        break;
                    }
                }
                for(int l=0;l<n;l++)
                {
                    if(q[l].f==1)
                    {
                        printf(" %s",q[l].a);
                    }
                }
                printf("\n");
            }
        }
    }
    return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值