2013. Neither shaken nor stirred

Time limit: 1.0 second
Memory limit: 64 MB
The ACM ICPC regional contest in St. Petersburg is a stressful event even for veterans of competetive programming. That’s why for the last four years programmer Denchik and his coach Vova go to their favorite bars to relax after the event. Having entered a bar, Denchik immediately orders cocktail “B-52”. If there is no such cocktail on the menu he drinks nothing. On the other hand, in places, where the cocktail is good, Denchik can repeat his order several times.
Vova, as an elder friend, tries to control his trainee drunkenness degree. When entering and leaving bars, Vova asks Denchik how many cocktails he has drunk in the last bar where B-52 was served. If Denchik is not sure about the answer, Vova considers Denchik’s drinking enough for this day and takes him to the hotel.
This year the story repeats again. Denchik has the experience of four previous regional contests and knows which bars serve B-52 and how many cocktails he’s going to drink in each bar at one visit. He also knows where they can go after leaving every bar on their route. For which bars Denchik may prepare right answers to Vova’s questions in advance, no matter what route they choose?

Input

The first line contains an integer n which is the number of bars (1 ≤ n ≤ 100 000). Next n lines describe these bars. The i-th line contains integers kimini1, ni2, …, nimi (0 ≤ ki ≤ 100 000; 0 ≤ mi ≤ n). If ki equals zero, then in bar i B-52 is not served, and if ki is positive, it means that Denchik will drink ki cocktails at one visit to bar ini1, ni2, …, nimi are the numbers of the bars friends can go to right after leaving bar i (1 ≤ nij ≤ nnij < ni,j+1). There can be number i among the numbers nij, and it means that after leaving bar i friends can hang around and enter the same bar again. The sum of all numbers mi does not exceed 100 000.
The bars are numbered in the order they are in the input data. Bar with number 1 is the bar from which Vova and Denchik begin their journey. It is guaranteed that during the night friends can reach every bar listed in the input.

Output

In the i-th of n lines output Denchik’s answers to Vova’s question on entering bar i and leaving it. Every answer should have one of the following forms:

  • sober, if Denchik hasn’t drunk any B-52 yet
  • X, if during the last visit to the bar where B-52 was served Denchik drunk X cocktails (X is an integer from 1 to 100 000)
  • unknown, if with different routes to the i-th bar different situations are possible

Samples

input output
5
0 2 2 3
6 1 4
5 2 4 5
5 1 5
0 0
sober sober
sober 6
sober 5
unknown 5
5 5
2
0 2 1 2
0 2 1 2
sober sober
sober sober
Problem Author: Alex Samsonov (prepared by Egor Shchelkonogov)
Problem Source: NEERC 2014, Eastern subregional contest
 
 
 
 

ural 2013 Neither shaken nor stirred的更多相关文章

  1. Neither shaken nor stirred(DFS理解+vector存图)

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=2013 题目理解: 给定n个点的有向图: 下面n行,第一个数字表示点权,后面一个数字m表示 ...

  2. NEERC 2014, Eastern subregional contest

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

  3. Motion——shake攻略

    1.子类化窗口 如果响应链中没有motionEnded:withEvent:消息的接收者,那么该消息就会被发送给应用程序的window对象.所以需要在window对象上拦截motionEnded:wi ...

  4. Ural 1960 Palindromes and Super Abilities

    Palindromes and Super Abilities Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged ...

  5. 2013 Asia Changsha Regional Contest---Josephina and RPG(DP)

    题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4800 Problem Description A role-playing game (RPG and ...

  6. SharePoint 2013: A feature with ID has already been installed in this farm

    使用Visual Studio 2013创建一个可视web 部件,当右击项目选择"部署"时报错: "Error occurred in deployment step ' ...

  7. Visual Studio 2013 添加一般应用程序(.ashx)文件到SharePoint项目

    默认,在用vs2013开发SharePoint项目时,vs没有提供一般应用程序(.ashx)的项目模板,本文解决此问题. 以管理员身份启动vs2013,创建一个"SharePoint 201 ...

  8. SharePoint 2013 create workflow by SharePoint Designer 2013

    这篇文章主要基于上一篇http://www.cnblogs.com/qindy/p/6242714.html的基础上,create a sample workflow by SharePoint De ...

  9. Install and Configure SharePoint 2013 Workflow

    这篇文章主要briefly introduce the Install and configure SharePoint 2013 Workflow. Microsoft 推出了新的Workflow ...

随机推荐

  1. 洛谷 P2721 小Q的赚钱计划

    洛谷 这大概是我见过最水的紫题吧- 洛谷标签赞一个! 题意:你有一年时间,把10w元存银行变成更多钱,在特定时间区间内,你会有一些利息,不过不可中途退出. 直接dp:st[i]表示区间左端点,ed[i ...

  2. Python迭代器包itertools(转)

    原文:http://www.cnblogs.com/vamei/p/3174796.html 作者:Vamei 在循环对象和函数对象中,我们了解了循环器(iterator)的功能.循环器是对象的容器, ...

  3. 转:9个offer,12家公司,35场面试 从微软到谷歌,应届计算机毕业生的2012求职之路 !!!

    1,简介 毕业答辩搞定,总算可以闲一段时间,把这段求职经历写出来,也作为之前三个半月的求职的回顾. 首先说说我拿到的offer情况: 微软,3面->终面,搞定 百度,3面->终面,口头of ...

  4. 3.7 基于51单片机+MC20的路径显示【使用STC15W内核】

    需要准备的硬件 MC20开发板 1个 https://item.taobao.com/item.htm?id=562661881042 GSM/GPRS天线 1根 https://item.taoba ...

  5. 剑指offer 面试20题

    面试20题: 题目:表示数值的字符串 题:请实现一个函数用来判断字符串是否表示数值(包括整数和小数).例如,字符串"+100","5e2","-123 ...

  6. IE浏览器连不上网,其他浏览器可以

    周末因工作需要,需用IE浏览器.结果发现IE连不上网,而其他浏览器正常上网. 首先排查不是网络连接问题. 又重启了一下网络连接.禁用---->启用. 还是不好使.(最后找到原因是DNS设置问题. ...

  7. Kattis - abc 【水】

    题意 给出三个数,然后给出一个顺序,有ABC三个字母构成, A是最大的数字 B是中间的数字 C是最小的数字 根据 ABC的顺序 给出 数字的顺序 思路 先排序一下,然后用 MAP 双向标记一下 AC代 ...

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

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

  9. 如何修改Eclipse中的快捷键

    首先打开Eclipse,Windows->Preferences ↓ 进入Preferences界面后,选择General->Keys ↓ 接下来你就会看到: 接下来点击OK就可以生效了.

  10. css背景透明文字不透明

    测试背景透明度为0.3.文字不透明: background-color: #000; /* 一.CSS3的opacity */ opacity: 0.3; /* 兼容浏览器为:firefox,chro ...