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. Python3基础 ** 幂运算 // 整除运算

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. POJ1144 Network(割点)题解

    Description A Telephone Line Company (TLC) is establishing a new telephone cable network. They are c ...

  3. HDU 2157(矩阵快速幂)题解

    How many ways?? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  4. 51nod 1080 两个数的平方和

    没心情写数学题啦啊   好难啊 #include<bits/stdc++.h> using namespace std; set<int> s; set<int>: ...

  5. Mac升级到EI Captain之后pip install 无法使用问题

    错误log: creating /System/Library/Frameworks/Python.framework/Versions/2.7/share error: could not crea ...

  6. spring cloud kubernetes之serviceaccount permisson报错

    spring boot项目引用spring-cloud-starter-kubernetes <dependency> <groupId>org.springframework ...

  7. plsql过期解决方法

    1.首先,登陆PL/SQL Developer,PL/SQL Developer要到期了 2.输入指令“regedit”打开注册表,如图所示 3.然后,在注册表里按HKEY_CURRENT_USER\ ...

  8. 关于iBatis配置xml文件时出现中文注释出错的一个问题(很坑爹.)

    才开始我没有使用SqlMap.properties来配置连接信息.所以直接用ctrl + shift + C然后往里面添加的中文注释 例: <!-- 注释--> 运行的时候报: Error ...

  9. MongoDB (课时1,2)

    1.数据库之中支持的的SQL语句是由IBM开发出来的,使用并不麻烦,就是几个简单的单词:select, from, where,  group by, having, order by.目前最流行的数 ...

  10. canvas和图片之间的互相装换

    canvas和图片之间的互相装换 一.总结 一句话总结:一个是canvas的drawImage方法,一个是canvas的toDataURL方法 canvas drawImage() Image对象 c ...