HDU 1707
思路:标记课程表上的课程,询问时遍历课程表,再以字典序输出名字。
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<memory.h>
#include<string.h>
#include<algorithm>
#include<cmath>
#include<stack>
const int MAXX= ;
const int mod=1e9+;
using namespace std;
typedef long long ll;
int T;
int n;
int q;
int k;
struct info
{
bool data[][];
char name[];
} per[]; struct pp
{
char ans[];
} w[]; bool cmp(pp a,pp b)
{
return strcmp(a.ans,b.ans)<;
} int main()
{
freopen("in.txt","r",stdin);
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
memset(per,,sizeof(per));
for(int i=; i<=n; i++)
{
int d,b,e;
scanf("%s%d",per[i].name,&k);
for(int j=; j<=k; j++)
{
scanf("%d%d%d",&d,&b,&e);
while(b<=e)
{
per[i].data[d][b]=;
b++;
}
//memset(per[i].data[d]+b,1,(e-b+1)*sizeof(per[i].data[0][0]));
}
}
scanf("%d",&q);
while(q--)
{
int d,b,e;
scanf("%d%d%d",&d,&b,&e);
//char newname[200][22];
int countt=;
for(int i=; i<=n; i++)
{
bool flag=;
for(int j=b; j<=e; j++)
{
if(per[i].data[d][j])
{
flag=;
break;
}
}
if(!flag)
{
strcpy(w[countt].ans,per[i].name);
countt++;
}
}
if(countt==)
{
cout<<"None"<<endl;
continue;
}
sort(w,w+countt,cmp);
for(int i=; i<countt; i++)
{
if(i)
printf(" ");
printf("%s",w[i].ans);
}
//printf("%s\n",newname[countt-1]);
printf("\n");
}
}
return ;
}
HDU 1707的更多相关文章
- HDU 1707 简单模拟 Spring-outing Decision
Spring-outing Decision Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- HDU 1710 二叉树的遍历 Binary Tree Traversals
Binary Tree Traversals Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- HDU 1708 简单dp问题 Fibonacci String
Fibonacci String Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 1710 Binary Tree Traversals(树的建立,前序中序后序)
Binary Tree Traversals Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- poj和hdu部分基础算法分类及难度排序
最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...
- hdu 1708 Fibonacci String
Fibonacci String Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- Fibonacci String(hdu 1708)
Fibonacci String Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
随机推荐
- mysql级联删除更新
首先,目前在产品环境可用的MySQL版本(指4.0.x和4.1.x)中,只有InnoDB引擎才允许使用外键,所以,我们的数据表必须使用InnoDB引擎. 下面,我们先创建以下测试用数据库表: CREA ...
- winserver2008,运行可执行文件,提示 激活上下文生成失败。 找不到从属程序集 Microsoft.VC90.DebugCRT,processorArchitecture="x86"
首先我运行的可执行文件是在win7下使用vs2008生成的release版本的文件,为什么在运行的时候提示需要DebugCRT? 另外我在winserver2008上是安装了vc2008的运行环境的. ...
- Nim语言:Pascal的语法,Python的缩进
http://nim-lang.org/ 德国人Andreas Rumpf的作品,原因是他对过去使用的每种语言都不满意(Pascal也不满意?).以前叫Nimrod语言,从0.96版本开始改名为Nim ...
- linux下,如何把整个文件夹上传到服务器(另一台linux)
1.Linux下目录复制:本机->远程服务器 scp -r /home/shaoxiaohu/test1 zhidao@192.168.0.1:/home/test2 #test1为源目录, ...
- 利用qt打开一张图片并转成灰度矩阵
首先是mat类,这个类的主要作用是构造一个容器,并将对应像素的灰度值放在容器内 #ifndef MAT_H #define MAT_H #include <vector> #include ...
- Vim的可视模式
可视模式可以看到选中的字符串, 并对其进行操作 v:进入字符选择模式 V:进入行选择模式 ctrl-v(Window是ctrl-q):进入block选择模式 o:移动光标到选择的另一端 O:移动光标到 ...
- Awesome-awesome-awesome
Awesome-awesome-awesome A curated list of curated lists of awesome lists. awesome-awesomes @sindreso ...
- poj 1699 Best Sequence (搜索技巧 剪枝 dfs)
题目链接 题意:给出几个基因片段,要求你将它们排列成一个最短的序列,序列中使用了所有的基因片段,而且不能翻转基因. 分析:先计算出add数组,再dfs枚举. 空间复杂度O(n*n), 最坏时间复杂度 ...
- 使用hibernate annotation 为非空列加上默认值
在网上查了很多资料都没找到如何为非空列加上默认值 以前的做法是给字段一个初始值,加上dynamic-insert属性 换了annotation了以后没有找到如何设置dynamic-insert属性 但 ...
- CodeForces 474.D Flowers
题意: 有n朵花排成一排,小明要么吃掉连续的k朵白花,或者可以吃单个的红花. 给出一个n的区间[a, b],输出总吃花的方法数模 109+7 的值. 分析: 设d(i)表示吃i朵花的方案数. 则有如下 ...