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 ...
随机推荐
- python 元组分组并排序
# -*- coding: utf-8 -*- # @Time : 2018/8/31 14:32 # @Author : cxa # @File : glomtest.py # @Software: ...
- ntp/系统时钟/硬件时钟/双系统下计算机时间读取的问题
http://blog.chinaunix.net/uid-182041-id-3464524.html //linux系统时间和硬件时钟问题(date和hwclock) http://j ...
- 你竟然在公钥中下毒!——如何在RSA公钥中添加后门
原文:http://www.hackdig.com/?01/hack-17893.htm 分享到: 当我知道它是如何运行时,我惊得下巴都掉了.这是一个非常简单的手法,但这篇文章会颠覆你之前对RSA的看 ...
- apache代理配置https
原文:https://mp.weixin.qq.com/s/Tw4UzX73Q7MSw3GJXnpN8A 微信小程序开发https设置 2017-04-06 格里菲斯 互联网工作者 微信官方规定小程序 ...
- Java事务管理之Hibernate
环境与版本 Hibernate 版本:Hibernate 4.2.2 (下载后的文件名为hibernate-release-4.2.2.Final.zip,解压目录hibernate-release- ...
- Jmeter的接口测试简介
一.安装Jmeter Jmeter官方首页:http://jmeter.apache. ...
- C# 图片和二进制之间的转换
1> 图片转二进制 public byte[] GetPictureData(string imagepath){/**/////根据图片文件的路径使用文件流打开,并保存为byte[] Fil ...
- .net/c#常用框架/中间件简介
任务调度 Quartz.NET:Quartz.NET是一个开源的作业调度框架,非常适合在平时的工作中,定时轮询数据库同步,定时邮件通知,定时处理数据等. Quartz.NET允 许开发人员根据时间间隔 ...
- Ubuntu 使用命令更新 Ubuntu 系统
我们都知道 Ubuntu 是一款 Linux 系统,是开源的系统,随时都在更新,所以人们都说 Linux 系统要比 Windows 系统安全.那么为了我们的电脑安全,我们如何利用 Ubuntu 命令来 ...
- PHP session 写入数据库中的方法
首先解释下为什么要把session 写到数据库中呢,session 一般默认是以文件的形式放在php.ini 配置的目录中的, 如果你的网站实现了多台服务器负载均衡,这样用户访问你的网站,可能进入的服 ...