CF1166E.The LCMs Must be Large

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Dora the explorer has decided to use her money after several years of juicy royalties to go shopping. What better place to shop than Nlogonia?

There are nn stores numbered from 11 to nn in Nlogonia. The ii-th of these stores offers a positive integer aia_i.

Each day among the last mm days Dora bought a single integer from some of the stores. The same day, Swiper the fox bought a single integer from all the stores that Dora did not buy an integer from on that day.

Dora considers Swiper to be her rival, and she considers that she beat Swiper on day ii if and only if the least common multiple of the numbers she bought on day ii is strictly greater than the least common multiple of the numbers that Swiper bought on day ii.

The least common multiple (LCM) of a collection of integers is the smallest positive integer that is divisible by all the integers in the collection.

However, Dora forgot the values of aia_i. Help Dora find out if there are positive integer values of aia_i such that she beat Swiper on every day. You don't need to find what are the possible values of aia_i though.

Note that it is possible for some values of aia_i to coincide in a solution.

探险家朵拉在获得了多年丰厚的版税收入后,决定去购物。还有什么地方比 Nlogonia 更适合购物呢?

Nlogonia 共有 nn 家商店,编号从 11 到 nn。第 ii 家商店提供一个正整数 aia_i。

在最近的 mm 天中,朵拉每天都会从其中某家商店购买一个整数。同一天,狐狸斯威珀则会从朵拉当天未购买整数的所有商店中,各购买一个整数。

朵拉视斯威珀为自己的竞争对手;她认为自己在第 ii 天战胜了斯威珀,当且仅当:她当天所购数字的最小公倍数(LCM) 严格大于斯威珀当天所购数字的最小公倍数。

一组整数的最小公倍数(LCM)是指能被该组中所有整数整除的最小正整数。

然而,朵拉忘记了各 aia_i 的具体取值。请帮朵拉判断:是否存在一组正整数 aia_i,使得她在每一天都战胜斯威珀?你无需具体求出这些 aia_i 的可能取值。

注意:在满足条件的一组解中,某些 aia_i 的值可以相等。

输入格式

The first line contains integers mm and nn (1≤m≤501\leq m \leq 50, 1≤n≤1041\leq n \leq 10^4) — the number of days and the number of stores.

After this mm lines follow, the ii-th line starts with an integer sis_i (1≤si≤n−11\leq s_i \leq n-1), the number of integers Dora bought on day ii, followed by sis_i distinct integers, the indices of the stores where Dora bought an integer on the ii-th day. The indices are between 11 and nn.

第一行包含两个整数 mm 和 nn(1≤m≤501\leq m \leq 50,1≤n≤1041\leq n \leq 10^4)——分别表示天数和商店数量。

接下来是 mm 行,其中第 ii 行首先是一个整数 sis_i(1≤si≤n−11\leq s_i \leq n-1),表示 Dora 在第 ii 天购买的整数个数;随后是 sis_i 个互不相同的整数,表示 Dora 在第 ii 天购买整数的那些商店的编号。这些编号均在 11 到 nn 之间。

输出格式

Output must consist of a single line containing "possible" if there exist positive integers aia_i such that for each day the least common multiple of the integers bought by Dora is strictly greater than the least common multiple of the integers bought by Swiper on that day. Otherwise, print "impossible".

Note that you don't have to restore the integers themselves.

输出必须为单行,如果存在正整数 aia_i,使得对每一天,Dora 所购整数的最小公倍数严格大于 Swiper 所购整数的最小公倍数,则输出 "possible";否则输出 "impossible"。

注意:你无需恢复这些整数本身。

输入输出样例

  • 输入#1

    2 5
    3 1 2 3
    3 3 4 5

    输出#1

    possible
  • 输入#2

    10 10
    1 1
    1 2
    1 3
    1 4
    1 5
    1 6
    1 7
    1 8
    1 9
    1 10

    输出#2

    impossible

说明/提示

In the first sample, a possible choice for the values of the aia_i is 3,4,3,5,23, 4, 3, 5, 2. On the first day, Dora buys the integers 3,43, 4 and 33, whose LCM is 1212, while Swiper buys integers 55 and 22, whose LCM is 1010. On the second day, Dora buys 3,53, 5 and 22, whose LCM is 3030, and Swiper buys integers 33 and 44, whose LCM is 1212.

在第一个样例中,aia_i 的一个可能取值为 3,4,3,5,23, 4, 3, 5, 2。第一天,Dora 购买了整数 3,43, 4 和 33,它们的最小公倍数(LCM)为 1212;而 Swiper 购买了整数 55 和 22,它们的最小公倍数为 1010。第二天,Dora 购买了 3,53, 5 和 22,它们的最小公倍数为 3030;Swiper 购买了整数 33 和 44,它们的最小公倍数为 1212。

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

首页