DESCRIPTION: 大意是说 先给你n个 同学的 上课时间。一周的第几天,开始和结束的时间点。然后对应q个出去玩的时间。要你给出谁不能出去。如果都能出去就输出none。

开始做的时候觉得每个同学的上课信息太多了。还要更新。不知道用什么方法存储。看题解,居然是二维数组8*12....好机智的说....

附代码:
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<algorithm>
using namespace std;

struct Lesson
{
    string name;
    int time[8][12];   //以数组里的数字是1还是0来保存 这个时刻是不是有空。
}lesson[225];

int main()
{
    int t, n;
    cin >> t;
    while(t--)
    {
        cin >> n;
        for (int i=0; i<225; ++i)
        {
            memset(lesson[i].time, 0, sizeof(lesson[i].time));
        }
        for (int i=0; i<n; ++i)              
        {
            int k;
            cin >> lesson[i].name >> k;
            for (int j=0; j<k; ++j)
            {
                int d, b, e;
                cin >> d >> b >> e;
                for (int kk=b; kk<=e; ++kk)
                {
                    lesson[i].time[d][kk] = 1;
                }
            }
        }
        int q;
        cin >> q;
        string name[225];
        for (int i=0; i<q; ++i)
        {
            int cnt = 0;
            int d, b, e;
            cin >> d >> b >> e;
            for (int j=0; j<n; ++j)
            {
                for (int kk=b; kk<=e; ++kk)
                {
                    if (lesson[j].time[d][kk] == 1)
                    {
                        name[cnt++] = lesson[j].name;
                        break;
                    }
                }
            }
            if (cnt == 0)
            {
                cout << "None\n";
                continue;
            }
            sort(name, name+cnt);
            for (int j=0; j<cnt; ++j)
            {
                 if (j == 0)
                    cout << name[j];
                 else cout << ' ' << name[j];
            }
            cout << endl;
        }
    }
    return 0;
}

HDU 2891的更多相关文章

  1. hdu 2891 中国剩余定理

    从6点看到10点,硬是没算出来,早知道玩游戏去了,艹,明天继续看 不爽,起来再看,终于算是弄懂了,以后超过一个小时的题不会再看了,不是题目看不懂,是水平不够 #include<cstdio> ...

  2. 一些关于中国剩余定理的数论题(POJ 2891/HDU 3579/HDU 1573/HDU 1930)

    2891 -- Strange Way to Express Integers import java.math.BigInteger; import java.util.Scanner; publi ...

  3. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. JS引擎深入分析

    转载自阮一峰:http://javascript.ruanyifeng.com/bom/engine.html 目录 JavaScript代码嵌入网页的方法 script标签:代码嵌入网页 scrip ...

  2. Educational Codeforces Round 21 Problem D(Codeforces 808D)

    Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into t ...

  3. [c/c++]指针(3)

    在指针2中提到了怎么用指针申配内存,但是,指针申配的内存不会无缘无故地 被收回.很多poj上的题都是有多组数据,每次地数组大小会不同,所以要重新申请 一块内存.但是原来的内存却不会被收回,也是说2.3 ...

  4. JavaScript new return 类的实例化

    new初始化方法 简单没有return的就不写了 function Person() { this.name="hongda"; ; return "fffffff&qu ...

  5. Large Division(大数)题解

    Given two integers, a and b, you should check whether a is divisible by b or not. We know that an in ...

  6. spring boot 使用@ConfigurationProperties

    有时候有这样子的情景,我们想把配置文件的信息,读取并自动封装成实体类,这样子,我们在代码里面使用就轻松方便多了,这时候,我们就可以使用@ConfigurationProperties,它可以把同类的配 ...

  7. Java 类引入 学习记录规整

    之前觉得声明一个类,再把另一个包内的声明数值用第一个类打印出来就可以了(加入引入包类) 结果发现是不对的 看了看demo  得出正确结果    ImportTest 被运行 引入下面的Import类 ...

  8. Unity3D学习笔记(二十四):MVC框架

    MVC:全名是Model-View-Controller View(视图层 - 顶层) Controller(控制层 - 中层) Model(数据层 - 底层) View(视图层) 说明:展现给玩家的 ...

  9. 项目梳理6——使用WebApiTestClient为webapi添加测试

    1.使用nuget添加WebApiTestClient的引用 2.xxxxx.WebApi\Areas\HelpPage\Views\Help\Api.cshtml页面末尾添加如下代码: @Html. ...

  10. Java DecimalFormat的主要功能及使用方法

    DecimalFormat 是 NumberFormat 的一个具体子类,用于格式化十进制数字.该类设计有各种功能,使其能够分析和格式化任意语言环境中的数,包括对西方语言.阿拉伯语和印度语数字的支持. ...