CF787B.Not Afraid

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Since the giant heads have appeared in the sky all humanity is in danger, so all Ricks and Mortys from all parallel universes are gathering in groups to find a solution to get rid of them.

There are n parallel universes participating in this event (n Ricks and n Mortys). I. e. each of n universes has one Rick and one Morty. They're gathering in m groups. Each person can be in many groups and a group can contain an arbitrary number of members.

Ricks and Mortys have registered online in these groups. So, a person can have joined a group more than once (developer of this website hadn't considered this possibility).

Summer from universe #1 knows that in each parallel universe (including hers) exactly one of Rick and Morty from that universe is a traitor and is loyal, but no one knows which one. She knows that we are doomed if there's a group such that every member in that group is a traitor (they will plan and destroy the world).

Summer knows that if there's a possibility that world ends (there's a group where all members are traitors) she should immediately cancel this event. So she wants to know if she should cancel the event. You have to tell her yes if and only if there's at least one scenario (among all 2_n_ possible scenarios, 2 possible scenarios for who a traitor in each universe) such that in that scenario the world will end.

由于巨型头颅出现在天空中,全人类正处于危险之中,因此来自所有平行宇宙的所有瑞克(Ricks)和莫蒂(Mortys)正分组聚集,以寻找消除这些巨型头颅的解决方案。

共有 nn 个平行宇宙参与本次活动(即 nn 个瑞克和 nn 个莫蒂)。换言之,每个平行宇宙中各有一名瑞克和一名莫蒂。他们共组成了 mm 个小组。每个人可加入多个小组,且每个小组可包含任意数量的成员。

瑞克和莫蒂已在线注册加入这些小组。因此,一个人可能多次注册加入同一个小组(该网站开发者未考虑到这种可能性)。

来自第 1 号宇宙的萨默(Summer)知道:在每个平行宇宙(包括她自己的宇宙)中,该宇宙的瑞克与莫蒂中恰好一人是叛徒,另一人是忠诚者;但没人知道具体谁是叛徒。

她还知道:若存在某个小组,其所有成员均为叛徒(他们将密谋并毁灭世界),则人类必将灭亡。

萨默清楚:只要存在某种可能导致世界毁灭的情形(即存在某个小组,其中所有成员均为叛徒),她就必须立即取消本次活动。因此,她想知道是否应取消本次活动。你需要告诉她“是”(yes),当且仅当在全部 2n2^n 种可能情形中(对每个宇宙,瑞克与莫蒂二者中谁是叛徒各有 2 种选择),至少存在一种情形使得世界会毁灭。

输入格式

The first line of input contains two integers n and m (1 ≤ n, m ≤ 104) — number of universes and number of groups respectively.

The next m lines contain the information about the groups. i-th of them first contains an integer k (number of times someone joined i-th group, k > 0) followed by k integers v__i, 1, v__i, 2, ..., v__i, k. If v__i, j is negative, it means that Rick from universe number  - v__i, j has joined this group and otherwise it means that Morty from universe number v__i, j has joined it.

Sum of k for all groups does not exceed 104.

输入的第一行包含两个整数 nn 和 mm(1≤n,m≤1041 \leq n, m \leq 10^4),分别表示宇宙的数量和组的数量。

接下来的 mm 行描述各组的信息。其中第 ii 行首先包含一个整数 kk(表示加入第 ii 组的总次数,k>0k > 0),随后是 kk 个整数 vi,1, vi,2, …, vi,kv_{i,1},\, v_{i,2},\, \dots,\, v_{i,k}。若 vi,jv_{i,j} 为负数,则表示来自编号为 −vi,j-v_{i,j} 的宇宙的 Rick 加入了该组;否则(即 vi,j≥0v_{i,j} \geq 0),表示来自编号为 vi,jv_{i,j} 的宇宙的 Morty 加入了该组。

所有组的 kk 值之和不超过 10410^4。

输出格式

In a single line print the answer to Summer's question. Print "YES" if she should cancel the event and "NO" otherwise.

在一行中输出 Summer 问题的答案。如果她应该取消该活动,则输出 “YES”,否则输出 “NO”。

输入输出样例

  • 输入#1

    4 2
    1 -3
    4 -2 3 2 -3

    输出#1

    YES
  • 输入#2

    5 2
    5 3 -2 1 -1 5
    3 -5 2 5

    输出#2

    NO
  • 输入#3

    7 2
    3 -1 6 7
    7 -5 4 2 4 7 -3 4

    输出#3

    YES

说明/提示

In the first sample testcase, 1st group only contains the Rick from universe number 3, so in case he's a traitor, then all members of this group are traitors and so Summer should cancel the event.

在第一个样例测试用例中,第 1 组仅包含来自编号为 3 的宇宙的瑞克(Rick),因此,若他是叛徒,则该组所有成员均为叛徒,于是萨默(Summer)应取消此次活动。

输入解题思路,AI测评打分。不知道怎么写?

首页