A12621 | The LCMs Must be Large
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 $n$ stores numbered from $1$ to $n$ in Nlogonia. The $i$ -th of these stores offers a positive integer $a_i$ .
Each day among the last $m$ 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 $i$ if and only if the least common multiple of the numbers she bought on day $i$ is strictly greater than the least common multiple of the numbers that Swiper bought on day $i$ .
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 $a_i$ . Help Dora find out if there are positive integer values of $a_i$ such that she beat Swiper on every day. You don't need to find what are the possible values of $a_i$ though.
Note that it is possible for some values of $a_i$ to coincide in a solution.
There are $n$ stores numbered from $1$ to $n$ in Nlogonia. The $i$ -th of these stores offers a positive integer $a_i$ .
Each day among the last $m$ 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 $i$ if and only if the least common multiple of the numbers she bought on day $i$ is strictly greater than the least common multiple of the numbers that Swiper bought on day $i$ .
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 $a_i$ . Help Dora find out if there are positive integer values of $a_i$ such that she beat Swiper on every day. You don't need to find what are the possible values of $a_i$ though.
Note that it is possible for some values of $a_i$ to coincide in a solution.
输入格式
The first line contains integers $m$ and $n$ ( $1\leq m \leq 50$ , $1\leq n \leq 10^4$ ) — the number of days and the number of stores.
After this $m$ lines follow, the $i$ -th line starts with an integer $s_i$ ( $1\leq s_i \leq n-1$ ), the number of integers Dora bought on day $i$ , followed by $s_i$ distinct integers, the indices of the stores where Dora bought an integer on the $i$ -th day. The indices are between $1$ and $n$ .
After this $m$ lines follow, the $i$ -th line starts with an integer $s_i$ ( $1\leq s_i \leq n-1$ ), the number of integers Dora bought on day $i$ , followed by $s_i$ distinct integers, the indices of the stores where Dora bought an integer on the $i$ -th day. The indices are between $1$ and $n$ .
输出格式
Output must consist of a single line containing "possible" if there exist positive integers $a_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.
Note that you don't have to restore the integers themselves.
输入输出样例
输入 #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 $a_i$ is $3, 4, 3, 5, 2$ . On the first day, Dora buys the integers $3, 4$ and $3$ , whose LCM is $12$ , while Swiper buys integers $5$ and $2$ , whose LCM is $10$ . On the second day, Dora buys $3, 5$ and $2$ , whose LCM is $30$ , and Swiper buys integers $3$ and $4$ , whose LCM is $12$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted