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. WIN文件放到LINUX中无法CAT过滤的解决方法

    有个WIN文件放到LINUX服务器上处理的时候,由于编码的问题,导致无法过滤,此时需要对文件进行处理 cat file | tr -s "\r" "\n" &g ...

  2. Java并发—线程常用方法总结

    1.join()方法 join —— 让一个线程等待另一个线程完成才继续执行.如A线程线程执行体中调用B线程的join()方法,则A线程被阻塞,知道B线程执行完为止,A才能得以继续执行. public ...

  3. MySQL的SQL MODE

    SQL MODE:定义mysqld对约束等的响应行为:    查看当前模式:        mysql> SHOW GLOBAL VARIABLES LIKE 'sql_mode';    修改 ...

  4. What's the difference between 'Even if' and 'Even though'?

    为一个英语词组语法写一篇Blog: even if 与 even though 这两个词组大致意思相当,但强调的侧重有所不同. even if与even though的区别: even if一般引导的 ...

  5. Confluent介绍

    Building a Scalable ETL Pipeline in 30 Minutes confluent介绍: LinkedIn有个三人小组出来创业了—正是当时开发出Apache Kafka实 ...

  6. $Android AlertDialog的各种用法总结

    Refer:http://www.2cto.com/kf/201205/131876.html (一)最简单的用法(详见注释) 1 // 1.创建简单的AlertDialog // AlertDial ...

  7. hadoop06---多线程

    .1.1. 实现线程的两种方式 1.继承Thread的方式 见代码MyThreadWithExtends 2.声明实现 Runnable 接口的方式 见代码MyThreadWithImpliment ...

  8. Linux Shell基础 环境变量配置文件

    source命令:使环境变量配置文件强制生效 source 命令会强制执行脚本中的全部命令,而忽略脚本文件的权限.该命令主要用于让重新配置的环境变量配置文件强制生效.source 命令格式如下: [r ...

  9. Python自然语言处理系列之模拟退火算法

    1.基本概念 模拟退火算法(Simulated Annealing,SA)是一种模拟固体降温过程的最优化算法.其模拟的过程是首先将固体加温至某一温度,固体内部的粒子随温度上升慢慢变为无序的状态,内能增 ...

  10. Android相机实时自动对焦的完美实现

    https://zhidao.baidu.com/question/873328177698804372.html Android相机实时自动对焦的完美实现 http://blog.csdn.net/ ...