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. Hexo+yilia博客添加背景音乐

    个人主页:https://www.yuehan.online 现在博客:www.wangyurui.top 第一步: 打开网易云音乐的官网:https://music.163.com/ 第二步: 搜索 ...

  2. 001-Java®语言规范、Java平台标准版文档、JVM概述

    一.概述 相关api地址:JDK10   JDK 9   JDK 8   JDK 7   JDK 6 Java语言和虚拟机规范: https://docs.oracle.com/javase/spec ...

  3. iOS Swift 熊猫🐼跑酷 第一个小项目

    前言:想用swift  写个小游戏 慢慢转化 能写出 ARKit来.但是又不能一口吃个胖子,慢慢来,在网络视频教程中撸了视频教学,断断续续看了半个多月,基本实现了 游戏主角

  4. OS X 与传统Unix的一点区别

    在传统的Unix系统或者Linux系统中,你是很难在根目录下找到大写开头的文件夹的, 但是看一下OS X: ls / Applications Users etc private var Develo ...

  5. $Java设计模式之——观察者模式(Observer)

    (一)观察者模式简介 1.定义:定义对象间一种一对多的依赖关系,一个对象状态发生改变时,所有依赖它的对象都会接到通知并作出相应的响应. 2.应用场景: (1)GUI系统 (2)订阅-发布系统 (3)事 ...

  6. Keepalived 主备配置

    keepalived主备或多主多备,配置都是一样配置方法,只是搭建多少的问题. 1.keepalived安装 参考:https://www.cnblogs.com/zwcry/p/9542867.ht ...

  7. 系统封装接口层 cmsis_os

    在这个实时操作系统泛滥的年代,有这么一个系统封装接口层还是蛮有必要的.前些时间偶然间在STM32最新的固件库中就发现了这个系统封装接口,当时就把自己所用的系统进行封装.直到最近KEIL5.0发现其中所 ...

  8. MySQL数据库基本操作(一)

    进入mysql 本地连接: mysql -u用户名 -p 输入密码 qwe123 mysql -uroot -pqwe123 sudo apt-get install mysql-server # p ...

  9. Xib与Storyboard相关知识点

    相同点 都用来描述软件界面 都用Interface Builder工具来编辑 本质都是转换成代码去创建控件 不同点 Xib是轻量级的,用来描述局部的UI界面 Storyboard是重量级的,用来描述整 ...

  10. android开发之如何将一般应用变身系统级应用【转】

    本文转载自:https://blog.csdn.net/zanelove/article/details/43953743 前提: ROOT过的手机 1,把代码编写好后,打包导出apk,copy到手机 ...