题库练习 A Serious Referee
← 上一题 下一题 →

A14408 | A Serious Referee

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Andrea has come up with what he believes to be a novel sorting algorithm for arrays of length $n$ . The algorithm works as follows.

Initially there is an array of $n$ integers $a_1,\, a_2,\, \dots,\, a_n$ . Then, $k$ steps are executed.

For each $1\le i\le k$ , during the $i$ -th step the subsequence of the array $a$ with indexes $j_{i,1}< j_{i,2}< \dots< j_{i, q_i}$ is sorted, without changing the values with the remaining indexes. So, the subsequence $a_{j_{i,1}},\, a_{j_{i,2}},\, \dots,\, a_{j_{i,q_i}}$ is sorted and all other elements of $a$ are left untouched.

Andrea, being eager to share his discovery with the academic community, sent a short paper describing his algorithm to the journal "Annals of Sorting Algorithms" and you are the referee of the paper (that is, the person who must judge the correctness of the paper). You must decide whether Andrea's algorithm is correct, that is, if it sorts any array $a$ of $n$ integers.

输入格式

The first line contains two integers $n$ and $k$ ( $1\le n\le 40$ , $0\le k\le 10$ ) — the length of the arrays handled by Andrea's algorithm and the number of steps of Andrea's algorithm.

Then $k$ lines follow, each describing the subsequence considered in a step of Andrea's algorithm.

The $i$ -th of these lines contains the integer $q_i$ ( $1\le q_i\le n$ ) followed by $q_i$ integers $j_{i,1},\,j_{i,2},\,\dots,\, j_{i,q_i}$ ( $1\le j_{i,1}<j_{i,2}<\cdots<j_{i,q_i}\le n$ ) — the length of the subsequence considered in the $i$ -th step and the indexes of the subsequence.

输出格式

If Andrea's algorithm is correct print ACCEPTED, otherwise print REJECTED.

输入输出样例

输入 #1
4 3
3 1 2 3
3 2 3 4
2 1 2
输出 #1
ACCEPTED
输入 #2
4 3
3 1 2 3
3 2 3 4
3 1 3 4
输出 #2
REJECTED
输入 #3
3 4
1 1
1 2
1 3
2 1 3
输出 #3
REJECTED
输入 #4
5 2
3 2 3 4
5 1 2 3 4 5
输出 #4
ACCEPTED
C++ 编辑器
输入
输出