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) ...
随机推荐
- Easyui 中的placeholder属性
在 easyui有文档中,没注意还真找不到placeholder属性,因为在属性只在searchbox中提到了, <input id="ss" class="eas ...
- linux下,如何把整个文件夹上传到服务器(另一台linux)
1.Linux下目录复制:本机->远程服务器 scp -r /home/shaoxiaohu/test1 zhidao@192.168.0.1:/home/test2 #test1为源目录, ...
- Hibernate 多表关联
hibernate中可以一次对多个表进行数据插入,这种插入类似 Hibernate的关联映射关系有:多对一 ---- many-to-one一对多 ---- one-to-many一对一 ---- o ...
- QTP场景恢复之用例失败自动截图
以下代码是在QC里运行QTP来执行脚本过程,当执行过程中发现用例失败后就会自动截图,然后把用例返回到最初始的状态,模拟了场景恢复的机制 Class QCImageErrorCapture Dim qt ...
- MySQL学习笔记一
MySQL 学习笔记 一 一.数据库简单介绍 1. 按照数据库的发展时间顺序,主要出现了以下类型数据库系统: Ø 网状型数据库 Ø 层次型数据库 Ø 关系型数据库 Ø 面向对象数据库 上面4中数据库系 ...
- 宏HASH_SEARCH
/********************************************************************//** Looks for a struct in a ha ...
- bzoj3632
裸的最大团,随机化大法好 多次随机出一个选择顺序然后贪心即可 ..,..] of boolean; a:..] of longint; v:..] of boolean; n,m,i,j,x,y,an ...
- 发布 windows 10 universal app 时微软账号验证失败
具体错误:Visual Studio encountered an unexpected network error and can't contact the Microsoft account s ...
- UVa 11732 (Tire树) "strcmp()" Anyone?
这道题也是卡了挺久的. 给出一个字符串比较的算法,有n个字符串两两比较一次,问一共会有多少次比较. 因为节点会很多,所以Tire树采用了左儿子右兄弟的表示法来节省空间. 假设两个不相等的字符串的最长公 ...
- Selenium Tutorial (2) - Selenium IDE In Depth
Installing Firefox and Firebug Installing and Opening Selenium IDE Starting with test cases and test ...