我是靠谱客的博主 缓慢海燕,这篇文章主要介绍Spring-outing DecisionSpring-outing Decision ,现在分享给大家,希望可以做个参考。

Spring-outing Decision

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 20   Accepted Submission(s) : 3
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 Kline2: day1 b1 e1.....lineK+1: dayK bK eKThe 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
 
这个题就是需要输入和处理的数据种类较多,我们用结构体的话会比较方便,名字在结构体里面,在创立一个二维数组,a[i][j] i是星期,j是每天的课
,着样处理的话就会非常方便,然后暴力的处理题目。注意最后输出的时候要用到sort排序,因为名字要按字典排序。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<algorithm>
using namespace std;
struct studdent
{
    string name;//名字
    int a[20][20];//星期和课程。
}s[205];
int main()
{
    int t,n,x,y,q,q1,q2,q3,i,j,h,m,g,f,c;
    string str[205];
    cin>>t;
    while(t--)
    {
        cin>>n;
        for(i=0;i<n;i++)
        {
            memset(s[i].a,0,sizeof(s[i].a));//清空二维数组的数据。
            cin>>s[i].name;
            cin>>m;
            while(m--)
            {
                scanf("%d%d%d",&q,&x,&y);
                h=q;
                for(j=x;j<=y;j++)
                {
                    s[i].a[h][j]=1;
                }
            }
        }
        cin>>g;
        while(g--)
        {
            c=0;
        scanf("%d%d%d",&q1,&q2,&q3);
        for(i=0;i<n;i++)
        {
            h=q1;
            f=0;
            for(j=q2;j<=q3;j++)
            {
            if(s[i].a[h][j]!=0)
            {
                f=1;
            }
            }
            if(f==1)
            {
                str[c]=s[i].name;
                c++;
            }
        }
        if(c==0)printf("Nonen");
        else
        {
            sort(str,str+c);//排序。
            cout<<str[0];
            for(i=1;i<c;i++)
            {
                cout<<" "<<str[i];
            }
            printf("n");
        }
        }
    }
}

最后

以上就是缓慢海燕最近收集整理的关于Spring-outing DecisionSpring-outing Decision 的全部内容,更多相关Spring-outing内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部