SGU 406 Goggle
406. Goggle
Memory limit: 65536
kilobytes
output: standard
Everybody
 knows search engine Goggle. But only advanced users know that it is
possible to search number sequences. You can enter a set of numbers and
the search engine will find all sequences which contain it. Goggle
developers decided to improve the engine. New feature will help you if
you know numbers which shouldn't be in the result. These numbers must be
 entered with the opposite sign. For example, if somebody enters "5 -3
6", the engine will find all the sequences which contain 5 and 6, but do
 not contain 3.
Help Goggle developers to implement the feature.
The first line of the input will contain two integer numbers n and m (1 ≤ n ≤ 10, 1 ≤ m ≤ 10), where n is the number of sequences in Goggle database and m is the number of queries. Following n lines describe sequences in the Goggle database. The first integer k in each line is the length of the sequence (1 ≤ k ≤ 10). Next k numbers are the sequence elements. All of them are integers between 1 and 100, inclusive. Following m lines describe queries. The first integer l of each line is the numbers in query (1 ≤ l ≤ 10). Next l numbers bi are the sequence elements (1 ≤ |bi| ≤ 100, bi ≠ 0). These numbers have different absolute values.
For each query print t — the number of found sequences on a separate line. Each of the next t
 lines should contain found sequence. The relative order of sequences
should be preserved (in compliance with the input). The order of numbers
 in sequences should not change (in compliance with the input). Write
sequences in format as they were given in the input.
| sample input | sample output | 
| 3 5 | 1 | 
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
#define maxn 200
using namespace std;
int len[maxn],a[maxn],b[maxn][maxn],hh[maxn][maxn],res[maxn];
int tot,n,m,lend,flag;
int main(){
//freopen("test.in","r",stdin);
scanf("%d%d",&n,&m);
memset(hh,,sizeof(hh));
for(int i=;i<=n;i++){
scanf("%d",&len[i]);
for(int j=;j<=len[i];j++) scanf("%d",&b[i][j]),hh[i][b[i][j]]++;
}
for(int i=;i<=m;i++){
tot=;
scanf("%d",&lend);
for(int j=;j<=lend;j++) scanf("%d",&a[j]);
for(int j=;j<=n;j++){
flag=;
for(int k=;k<=lend;k++)
if((a[k]>&&hh[j][a[k]])||(a[k]<&&!hh[j][-a[k]])) continue;
else flag=;
if(flag) res[++tot]=j; }
printf("%d\n",tot);
for(int j=;j<=tot;j++){
printf("%d",len[res[j]]);
for(int k=;k<=len[res[j]];k++) printf(" %d",b[res[j]][k]);
printf("\n");
}
} }
SGU 406 Goggle的更多相关文章
- 【406错误】 The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
		今天遇到一个奇怪的错误,关于Springmvc的,我明明在Controller方法中写了@ResponseBody,返回一个Map,结果报了406错误. 结果发现,少了一个jar包: 加上去就没事了. 
- leetcode 406
		该算法题就是leetcode 406题, 题目描述: Suppose you have a random list of people standing in a queue. Each person ... 
- Spring MVC Rest服务 返回json报406错误的解决办法
		@ResponseBody & @RequestBody @RequestBody 将 HTTP 请求正文插入方法中,使用适合的HttpMessageConverter将请求体写入某个对象. ... 
- Spring MVC 4.1.4 RESTFUL风格返回JSON数据406错误处理
		Spring MVC 4.1.4 RESTFUL风格返回JSON数据406错误处理 今天在使用spring4.1.4,使用ResponseBody注解返回JSON格式的数据的时候遇到406错误. 解决 ... 
- POSTMAN发起请求收到乱码 http 406错误
		web前段异常: The resource identified by this request is only capable of generating responses with charac ... 
- SGU 495. Kids and Prizes
		水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ... 
- ACM:   SGU 101 Domino- 欧拉回路-并查集
		sgu 101 - Domino Time Limit:250MS Memory Limit:4096KB 64bit IO Format:%I64d & %I64u Desc ... 
- 【SGU】495. Kids and Prizes
		http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ... 
- Spring mvc 下Ajax获取JSON对象问题 406错误
		我在学习springmvc过程中(我的项目是配置的后缀是.html),从controller返回对象. 如果我不使用 mvc-annotation-driver,而是手动配置,AnnotationMe ... 
随机推荐
- Android调试大法 自定义IDE默认签名文件==>微信支付、微信登录、微信分享,debug时调试通过,release时调不起微信
			转载地址:http://blog.yanzhenjie.com Android调试大法之自定义IDE默认签名文件,你是否为调试第三方SDK时debug签名和release签名发生冲突而烦恼?你是否在d ... 
- 【Android开发日记】之入门篇(十二)——Android组件间的数据传输
			组件我们有了,那么我们缺少一个组件之间传递信息的渠道.利用Intent做载体,这是一个王道的做法.还有呢,可以利用文件系统来做数据共享.也可以使用Application设置全局数据,利用组件来进行控制 ... 
- CentOS7的firewall和安装iptables
			前言:CentOS7 的防火墙默认使用是firewall,而我们通常使用iptables: 本文记录了firewall基础的命令和iptables的安装和使用. firewall部分: part1 : ... 
- 动态页面技术JSP/EL/JSTL
			本节内容: jsp脚本和注释 jsp运行原理 jsp指令(3个) jsp内置/隐式对象(9个) jsp标签(动作) EL技术 JSTL技术 JavaEE的开发模式 动态页面技术:就是在html中嵌入j ... 
- jsonrpc.js -- 原生js实现 JSON-RPC 协议
			很早以前就涉及到多端远程调用 api的设计,那时候自己设计了个消息传递回调过程.最近了解了JSON-RPC协议,更正规,就可以自己实现下.逻辑也不复杂,没有限制底层消息传递的方式,可以应用到更多的场景 ... 
- scrapy中对于item的把控
			其实很简单,就是想要存储的位置发生改变.直接看例子,然后触类旁通. 以大众点评 评论的内容为例 ,位置:http://www.dianping.com/shop/77489519/review_mor ... 
- 【LOJ】#2037. 「SHOI2015」脑洞治疗仪
			题解 维护区间内1的个数,左边数0的长度,右边数0的长度,区间内0区间最长个数,覆盖标记 第一种操作区间覆盖0 第二种操作查询\([l_0,r_0]\)中1的个数,区间覆盖0,然后覆盖时找到相对应的区 ... 
- SPOJ - SUBLEX  后缀自动机
			SPOJ - SUBLEX 思路:求第k大字串,求出sam上每个节点开始能识别多少字串,然后从起点开始跑就好啦. #include<bits/stdc++.h> #define LL lo ... 
- Winsock—I/O模型之选择模型(一)
			Winsock中提供了一些I/O模型帮助应用程序以异步方式在一个或多个套接字上管理I/O. 这样的I/O模型有六种:阻塞(blocking)模型,选择(select)模型,WSAAsyncSelect ... 
- matplotlib 中文显示 的问题
			第一种方法 from pylab import mpl import numpy as np mpl.rcParams['font.sans-serif'] = ['SimHei'] # 指定默认字体 ... 
