HDU 2891
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的更多相关文章
- hdu 2891 中国剩余定理
从6点看到10点,硬是没算出来,早知道玩游戏去了,艹,明天继续看 不爽,起来再看,终于算是弄懂了,以后超过一个小时的题不会再看了,不是题目看不懂,是水平不够 #include<cstdio> ...
- 一些关于中国剩余定理的数论题(POJ 2891/HDU 3579/HDU 1573/HDU 1930)
2891 -- Strange Way to Express Integers import java.math.BigInteger; import java.util.Scanner; publi ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
随机推荐
- SPOJ LAS(BFS)题解
题目:VJ 思路: BFS+回溯,但是要剪枝,看了dalao的题解,超时+WA无数发,终于过了 #include<cstdio> #include<cstring> #incl ...
- swift设计模式学习 - 原型模式
移动端访问不佳,请访问我的个人博客 设计模式学习的demo地址,欢迎大家学习交流 原型模式 用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. 定义 用原型实例指定创建对象的种类,并且通 ...
- [bzoj 1270][BeijingWc2008]雷涛的小猫
Description 雷涛的小猫雷涛同学非常的有爱心,在他的宿舍里,养着一只因为受伤被救助的小猫(当然,这样的行为是违反学 生宿舍管理条例的). 在他的照顾下,小猫很快恢复了健康,并且愈发的活泼可 ...
- Faster-RCNN-TensorFlow-Python3.5 在Ubuntu16.04下的配置方法
目录 Faster-RCNN-TensorFlow-Python3.5 在Ubuntu16.04下的配置方法 安装过程 1. 深度学习环境Tensorflow的安装 2. 安装python包 3. ...
- UVa 10118 免费糖果(记忆化搜索+哈希)
https://vjudge.net/problem/UVA-10118 题意: 桌上有4堆糖果,每堆有N颗.佳佳有一个最多可以装5颗糖的小篮子.他每次选择一堆糖果,把最顶上的一颗拿到篮子里.如果篮子 ...
- UVa 1354 天平难题
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- MVC ---- EF高级增删改
//高级修改(创建对象) public void EditAdance(){ //创建要修改的对象 Parameter pm = new Parameter() { ParaNo = ", ...
- RTC(x86)
RTC 原创,转载请写明出处. 一直以来想写一篇关于RTC的总结,可是人太懒,在读完John Z. Sonmez大伽的<软技能代码之外的生存技能>后,终于下定决心,完成这项早已计划中的任务 ...
- c++ 二分法查找(binary_search)
#include <iostream> // cout #include <algorithm> // binary_search, sort #include <vec ...
- cocos2dx 在windows下开启console
cocos2dx 3.10 1.在main函数中写入代码 AllocConsole(); freopen("CONIN$", "r", stdin); freo ...