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 ...
随机推荐
- 转载:Google 官方应用架构的最佳实践指南 赞👍
官方给的实践指南,很有实际的指导意义, 特别是对一些小公司,小团队,给了很好的参考意义. 原文地址: https://developer.android.com/topic/libraries/ar ...
- Centos之命令搜索命令whereis与which
Centos之命令搜索命令whereis与which whereis 命令名 #搜索命令所在路径及帮助文档所在位置 选项: -b :只查找可执行文件位置 -m:只查找帮助文件 [root@localh ...
- MySQL学习笔记:三种组内排序方法
由于MySQ没有提供像Oracle的dense_rank()或者row_number() over(partition by)等函数,来实现组内排序,想实现这个功能,还是得自己想想办法,最终通过创建行 ...
- gcc中C++一个特别的头文件
今天在一段程序中看到这样一个很奇怪的语句: #include<bits/stdc++.h> 博主查了之后发现业界称其万能头文件,这个头文件包含了如下等头文件,几乎包含了所有的C++标准库头 ...
- 容器计划任务大坑:在alpine容器里,想用非root帐号执行crontab任务
我只能说抱歉,我前前后后测试了七天, 将自己预想的配置错误,一个一个去验证. 非root帐号在alpine容器里执行crontab任务,还是失败, 输出依旧是一片空白~ stackoverflow里, ...
- 1975: [Sdoi2010]魔法猪学院
k短路,只会写A*的飘过..priority_queue超空间差评!
- 成功实施的APS项目故事分享---如何管理与激励APS项目团队
故事背景 A企业是易普优APS重要客户之一,是某行业的龙头企业:APS项目历时7个月顺利上线,十个月验收!通过易普优APS的顺利实施,建成了集团的精益计划管控运营平台,树立计划的权威与指挥棒作用,让物 ...
- Ionic Js十九:加载动画
ion-spinner ionSpinner 提供了许多种旋转加载的动画图标.当你的界面加载时,你就可以呈现给用户相应的加载图标. 该图标采用的是SVG.  实例 HTML 代码 <ion-c ...
- IOS 本地推送
// 1.打开本地推送并设置属性 NSString *str = @"本地推送的信息"; UIApplication *app = [UIApplication sharedApp ...
- TradingView 为 k 线柱添加标记
看别人翻译的开发文档: 开发文档地址:https://zlq4863947.gitbooks.io/tradingview/ getMarks(symbolInfo, startDate, endDa ...