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) ...
随机推荐
- Hibernate逍遥游记-第10章 映射继承关系-001继承关系树中的每个具体类对应一个表
1. 2. <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate ...
- MultiSelectListPreference 的使用心得
最近在学习Android上的开发,打算做一个app.在做之前感觉很简单的功能,自己也有几年的C++经验,应该学起来很容易.但是事实告诉我,要注意的细节还是很多的. 大部分的app都会有设置页面, 用来 ...
- Failed to execute goal.....webxml attribute is required...
maven在打包项目的时候报错 Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-wa ...
- rhel-server-7.2-x86_64无法联网(VMware环境)
vim /etc/sysconfig/network-script vim ifcfg-eno16777736 (编辑网卡名) 将ONBOOT=NO更改为YES (启动network服务时是否启用该网 ...
- sonar runner 2.4
https://www.versioneye.com/java/org.codehaus.sonar.runner:sonar-runner-dist/2.4
- Android如何获取开机启动项列表
static final String BOOT_START_PERMISSION = "android.permission.RECEIVE_BOOT_COMPLETED"; p ...
- 29 个 PHP 的 Excel 处理类
下面的 PHP Excel 处理类中,包含 Excel 读写.导入导出等相关的类,列表如下: PHP Excel Reader classes 1. Read Excel Spreadsheets u ...
- 使用git对unity3d项目进行版本控制
http://stackoverflow.com/questions/18225126/how-to-use-git-for-unity-source-control The following is ...
- Hibernate4.2.2使用Annotation配置
1.在hibernate官网下载hibernate-release-4.2.2.Final.zip并解压 2.新建一个java project工程(20130619_Hibernate4.2.2_An ...
- servlet应用具体实例
web,xml应用文件 1.<filter>参数 <filter> <filter-name>encodingFilter</filter-name> ...