2017. Best of a bad lot

Time limit: 1.0 second
Memory limit: 64 MB
A cruise liner hasn’t moved away from the land even for three miles when it became apparent that somebody has drowned one of the stewards in the swimming pool. The captain promised to make an investigation personally and to throw the villains overboard. He is going to find the group of murderers by asking each of n passengers two following questions.
  1. Where were you at the moment of departure?
  2. Who did you see there?
The captain will make his decision based on contradictions in passengers’ testimonies. For example, if one passenger says that he was in his room, and another passenger says that he saw the first one near the swimming pool, then one of these two is for sure mixed up with murder. However, if passenger A didn’t see some other passenger B at the place, where passenger B really was, the captain wouldn’t consider it a contradiction, because passenger B could have just been unnoticed there.
The investigation is unlikely to be reliable, because the murderers have agreed that their testimonies will have no contradictions between them. As for the honest people, they have nothing to hide and will tell only the truth. You volunteered to compare the mismatches in the passengers’ answers and reveal a group of suspects. Moreover, you want to give out to the captain the smallest possible group of passengers. If somebody has to become the feeding stuff for sharks today, let as few people as possible suffer.

Input

The first line contains an integer n that is the number of the passengers (2 ≤ n ≤ 400). Next n lines contain the testimonies of each of the passengers. The i-th line starts with the place where the i-th passenger said he was at the moment of departure that is a non-empty string up to twenty lowercase Latin letters long. The place is followed by the list of the passengers the i-th passenger saw there in the form m nn2 … nm (0 ≤ m ≤ n − 1; 1 ≤ nj ≤ nnj ≠ inj < nj+1).

Output

In the first line output a positive integer that is the number of the passengers in the suspect group. In the second line output the numbers of these suspects in any order. If the problem has several solutions, output any of them. It is guaranteed that at least one solution exists.

Samples

input output
3
bar 0
bar 1 1
pool 2 1 2
1
3
3
pool 2 2 3
pool 2 1 3
pool 2 1 2
1
1

Notes

In the first example it is possible that both the first and the second passengers are murderers, and the third one tells the truth. But it is also possible that the first two tell the truth and the third one is a murderer. It is needed to output the second possibility since the group of suspects in it is smaller.
In the second example all passengers do not have testimony contradictions, so any of them could be a murderer.
Problem Author: Oleg Dolgorukov
Problem Source: NEERC 2014, Eastern subregional contest
 
 
 
 

ural 2017 Best of a bad lot的更多相关文章

  1. NEERC 2014, Eastern subregional contest

    最近做的一场比赛,把自己负责过的题目记一下好了. Problem B URAL 2013 Neither shaken nor stirred 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...

  2. 【构造】Ural Championship April 30, 2017 Problem K. King’s island

    题意:让你构造一个n个点的简单多边形,使得所有点是整点,并且所有边长是整数,并且没有边平行于坐标轴. 就利用勾股数,如下图这样构造即可,n为偶数时,只需矩形拼成,n为奇数时,封上虚线边即可. #inc ...

  3. 【哈希表】Ural Championship April 30, 2017 Problem H. Hamburgers

    题意:有n群人,每个人有喜欢的汉堡配方:有m家店,给出每家店的每个汉堡的配方,如果存在某个汉堡,其配料表包含某个人喜欢的配方,则这个人喜欢这个汉堡所在的店家.问你对每群人,输出被喜欢的人数最多的店面是 ...

  4. 【折半枚举】Ural Championship April 30, 2017 Problem G. Glasses with solutions

    题意:有n杯盐溶液,给定每杯里面盐的质量以及盐溶液的质量.问你有多少种方案选择一个子集,使得集合里面的盐溶液倒到一个被子里面以后,浓度为A/B. 折半枚举,暴力搜索分界线一侧的答案数,跨越分界线的答案 ...

  5. CI Weekly #10 | 2017 DevOps 趋势预测

    2016 年的最后几个工作日,我们对 flow.ci Android & iOS 项目做了一些优化与修复: iOS 镜像 cocoapods 版本更新: fir iOS上传插件时间问题修复: ...

  6. 猖獗的假新闻:2017年1月1日起iOS的APP必须使用HTTPS

    一.假新闻如此猖獗 刚才一位老同事 打电话问:我们公司还是用的HTTP,马上就到2017年了,提交AppStore会被拒绝,怎么办? 公司里已经有很多人问过这个问题,回答一下: HTTP还是可以正常提 ...

  7. iOS的ATS配置 - 2017年前ATS规定的适配

    苹果规定 从2017年1月1日起,新提交的 app 不允许使用NSAllowsArbitraryLoads来绕过ATS(全称:App Transport Security)的限制. 以前为了能兼容ht ...

  8. 深入研究Visual studio 2017 RC新特性

    在[Xamarin+Prism开发详解三:Visual studio 2017 RC初体验]中分享了Visual studio 2017RC的大致情况,同时也发现大家对新的Visual Studio很 ...

  9. Xamarin+Prism开发详解三:Visual studio 2017 RC初体验

    Visual studio 2017 RC出来一段时间了,最近有时间就想安装试试,随带分享一下安装使用体验. 1,卸载visual studio 2015 虽然可以同时安装visual studio ...

随机推荐

  1. 我的Android进阶之旅------>Android中编解码学习笔记

    编解码学习笔记(一):基本概念 媒体业务是网络的主要业务之间.尤其移动互联网业务的兴起,在运营商和应用开发商中,媒体业务份量极重,其中媒体的编解码服务涉及需求分析.应用开发.释放license收费等等 ...

  2. servle 3.0 新特性之一 对上传表单的支持

    1. 上传 * 上传对表单的要求: > method="post" > enctype="multipart/form-data",它的默认值是:a ...

  3. app开发需求文档怎么写

    我们在开发app前都会做需求分析,这个app开发需求文档怎么写呢?一般可以从这几点入手:确定APP方案的目标,APP方案的受众分析,APP开发方案功能设计,APP的操作系统说明方案,APP是是否是原生 ...

  4. 深度学习:Keras入门(二)之卷积神经网络(CNN)(转)

    转自http://www.cnblogs.com/lc1217/p/7324935.html 1.卷积与神经元 1.1 什么是卷积? 简单来说,卷积(或内积)就是一种先把对应位置相乘然后再把结果相加的 ...

  5. eval in Shell

    语法:eval cmdLine eval会对后面的cmdLine进行两遍扫描,如果第一遍扫描后,cmdLine是个普通命令,则执行此命令: 如果cmdLine中含有变量的间接引用,则保证间接引用的语义 ...

  6. Amend Last Commit选项使用注意点

    1.创建master分支并上传到remote分支 create 2 folders and 4 files 2.修改folder1/file1.java,commit并push. 3.修改folder ...

  7. bootstrap-select 使用笔记 设置选中值及手动刷新

    直接笔记: 1.页面刚加载完填充select选项数据时,需要手动刷新一下组件,否则没有选项值.(组件初始化时,li 与 option 分离的,需要刷新一下(据说)) $.post('/cpms/tod ...

  8. MySQL 数据库怎样把一个表的数据插入到另一个表

         web开发中,我们经常需要将一个表的数据插入到另外一个表,有时还需要指定导入字段,设置只需要导入目标表中不存在的记录,虽然这些都可以在程序中拆分成简单sql来实现,但是用一个sql的话,会节 ...

  9. xml转换为对象 微信接口

    public sealed class XMLSerilizable { /// <summary> /// XML转换为对象 /// </summary> /// <t ...

  10. 【leetcode刷题笔记】Median of Two Sorted Arrays

    There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted ...