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. 剑指Offer——跳台阶

    题目描述 一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法. 思路分析 这个问题可以先从简单开始考虑,台阶只有1阶,只有1种跳法,台阶有2阶,有2种跳法:一种两 ...

  2. BZOJ 3529 数表(莫比乌斯+树状数组)

    题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=3529 题意:有一张n×m的数表,其第i行第j列的数值为能同时整除i和j的所有自然数 ...

  3. git下载速度太慢【学习笔记】

    使用了sshFQ的伙伴添加这个配置下载速度有极大的提升. git config --global http.proxy 'socks5://127.0.0.1:1080'

  4. sql server文件另存为的时候,选择文件编码和换行

    文件编码 使用code page来标记的,没有找到utf8 without bom 换行

  5. System.ConfigurationManager类用于对配置文件的读取

    http://blog.csdn.net/ligenyingsr/article/details/54095986 System.ConfigurationManager类用于对配置文件的读取.其具有 ...

  6. Nexus Repository 搭建及使用

    Nexus Repository 是搭建maven的镜像的工具之一,在全球范围内使用挺广的. 一.Nexus 搭建过程 Nexus 镜像的搭建还是相对简单的,将下载的文件解压到相应的目录下,然后进入. ...

  7. 瞎折腾之Webhooks

    之前听学长介绍过webhooks,也知道有这个东西,但没有真正的用于项目部署,长久以来一直过着“刀耕火种”的生活......长久以来,都是这么更新代码的: 由于之前做的项目刚刚上线,需要对其进行持续的 ...

  8. LINUX设备驱动模型之class

    转自 https://blog.csdn.net/qq_20678703/article/details/52754661 1.LINUX设备驱动模型中的bus.device.driver,.其中bu ...

  9. python tar 压缩解压

    压缩: 1. import tarfile import os def tar(fname): t = tarfile.open(fname + ".tar.gz", " ...

  10. ubuntu 14.04 (desktop amd 64) 安装和配置ROS Indigo

    安装ROS 配置Ubuntu的软件源 配置Ubuntu要求允许接受restricted.universe和multiverse的软件源,可以根据下面的链接配置: https://help.ubuntu ...