406. Goggle

Time limit per test: 0.25 second(s)
Memory limit: 65536
kilobytes
input: standard
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.

Input

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.

Output

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.

Example(s)
sample input
sample output
3 5
6 1 2 3 1 2 3
4 3 2 4 5
2 4 2
3 1 2 3
2 3 2
3 2 -1 3
2 4 -2
2 4 5
1
6 1 2 3 1 2 3
2
6 1 2 3 1 2 3
4 3 2 4 5
1
4 3 2 4 5
0
1
4 3 2 4 5
 #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的更多相关文章

  1. 【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包: 加上去就没事了.

  2. leetcode 406

    该算法题就是leetcode 406题, 题目描述: Suppose you have a random list of people standing in a queue. Each person ...

  3. Spring MVC Rest服务 返回json报406错误的解决办法

    @ResponseBody & @RequestBody @RequestBody 将 HTTP 请求正文插入方法中,使用适合的HttpMessageConverter将请求体写入某个对象. ...

  4. Spring MVC 4.1.4 RESTFUL风格返回JSON数据406错误处理

    Spring MVC 4.1.4 RESTFUL风格返回JSON数据406错误处理 今天在使用spring4.1.4,使用ResponseBody注解返回JSON格式的数据的时候遇到406错误. 解决 ...

  5. POSTMAN发起请求收到乱码 http 406错误

    web前段异常: The resource identified by this request is only capable of generating responses with charac ...

  6. SGU 495. Kids and Prizes

    水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...

  7. ACM: SGU 101 Domino- 欧拉回路-并查集

    sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Desc ...

  8. 【SGU】495. Kids and Prizes

    http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ...

  9. Spring mvc 下Ajax获取JSON对象问题 406错误

    我在学习springmvc过程中(我的项目是配置的后缀是.html),从controller返回对象. 如果我不使用 mvc-annotation-driver,而是手动配置,AnnotationMe ...

随机推荐

  1. RabbitMQ学习(一):RabbitMQ要点简介

    转载:http://blog.csdn.net/leixiaotao_java/article/details/78909760#t0 1.什么是RabbitMQ? RabbitMQ是由Erlang语 ...

  2. Python爬虫学习1: Requests模块的使用

    Requests函数库是学习Python爬虫必备之一, 能够帮助我们方便地爬取. Requests: 让HTTP服务人类. 本文主要参考了其官方文档. Requests具有完备的中英文文档, 能完全满 ...

  3. 错误/异常:The project cannot be built until build path errors are resolved 和 Unbound classpath container: 'JRE System Library [JavaSE-1.7]' in project 'MyJavaCode';的解决方法

    错误1: The project cannot be built until build path errors are resolved 解决方法: 把java的类库加载进去即可,在工程上右键 选择 ...

  4. 大数据竞赛平台——Kaggle 入门(转)

    先马克一下:http://blog.csdn.net/u012162613/article/details/41929171

  5. B树 B+树 红黑树

    B-Tree(B树) 具体讲解之前,有一点,再次强调下:B-树,即为B树.因为B树的原英文名称为B-tree,而国内很多人喜欢把B-tree译作B-树,其实,这是个非常不好的直译,很容易让人产生误解. ...

  6. ZooKeeper的基本概念(二)

    第一篇博文,我们对Zookeeper有了一个简单的认识,而且比较浅显,易懂,这篇博文,我们了解它的基本概念,如下图所示: 了解它的基本概念,有助于我们后面的学习,虽然今天的文章都是概念性质的内容,但是 ...

  7. Ansible playbook基础组件介绍

    本节内容: ansible playbook介绍 ansible playbook基础组件 playbook中使用变量 一.ansible playbook介绍 playbook是由一个或多个“pla ...

  8. 《精通Python设计模式》学习结构型之外观模式

    这个我在工作中也有所应用的. 就是在真正的实现层上面,再封装一个函数的调用的. 这样就可以在内层函数作真正实现, 而外层调用函数对外开放, 隔离内外的变化性. from enum import Enu ...

  9. swftools中的pdf2swf转换Error overflow ID 65535 解决办法

    近几日因为项目需要在线转换pdf到swf实现电子期刊阅读,用到了这个工具,版本是:swftools-0.9.2.tar.gz 当然也遇到了很头疼的问题,那就是在转换pdf中色彩图形比较复杂的页时会抛出 ...

  10. ASP.NET MVC之验证终结者篇

    有时候我觉得,很多人将一个具体的技术细节写的那么复杂,我觉得没有必要,搞得很多人一头雾水的,你能教会别人用就成了,具体的细节可以去查MSDN什么的,套用爱因斯坦的名言:能在网上查到的就不要去记,用的时 ...