A11271 | Rudolf and the Ball Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The first line of the input contains a single integer $t$ ( $1 \le t \le 10^4$ ) — the number of test cases. Then follow the descriptions of the test cases.
The first line of each test case contains three integers $n, m, x$ ( $2 \le n \le 1000$ , $1 \le m \le 1000$ , $1 \le x \le n$ ) — the number of players, the number of throws made, and the number of the player who threw the ball first, respectively.
The next $m$ lines contain information about each throw in order. Each of them contains an integer $r_i$ ( $1 \le r_i \le n - 1$ ) — the distance at which the $i$ -th throw was made, and a symbol $c_i$ , equal to '0', '1', or '?':
- if $c_i$ ='0', then the $i$ -th throw was made clockwise,
- if $c_i$ ='1', then the $i$ -th throw was made counterclockwise,
- if $c_i$ ='?', then Bernard does not remember the direction and the $i$ -th throw could have been made either clockwise or counterclockwise.
It is guaranteed that the sum $n \cdot m$ ( $n$ multiplied by $m$ ) over all test cases does not exceed $2 \cdot 10^5$ .
The first line of each test case contains three integers $n, m, x$ ( $2 \le n \le 1000$ , $1 \le m \le 1000$ , $1 \le x \le n$ ) — the number of players, the number of throws made, and the number of the player who threw the ball first, respectively.
The next $m$ lines contain information about each throw in order. Each of them contains an integer $r_i$ ( $1 \le r_i \le n - 1$ ) — the distance at which the $i$ -th throw was made, and a symbol $c_i$ , equal to '0', '1', or '?':
- if $c_i$ ='0', then the $i$ -th throw was made clockwise,
- if $c_i$ ='1', then the $i$ -th throw was made counterclockwise,
- if $c_i$ ='?', then Bernard does not remember the direction and the $i$ -th throw could have been made either clockwise or counterclockwise.
It is guaranteed that the sum $n \cdot m$ ( $n$ multiplied by $m$ ) over all test cases does not exceed $2 \cdot 10^5$ .
输入格式
For each test case, output two lines.
In the first line, output the number of players $k$ ( $1 \le k \le n$ ) who could have the ball at the end of the game.
In the next line, output $k$ numbers $b_i$ ( $1 \le b_i \le n$ ) — the numbers of the players in increasing order. All numbers must be different.
In the first line, output the number of players $k$ ( $1 \le k \le n$ ) who could have the ball at the end of the game.
In the next line, output $k$ numbers $b_i$ ( $1 \le b_i \le n$ ) — the numbers of the players in increasing order. All numbers must be different.
输出格式
Below is an illustration of three throws for the first test case. The arrows denote possible throw directions. Players who could have the ball after the throw are highlighted in gray.
  
  
输入输出样例
输入 #1
5 6 3 2 2 ? 2 ? 2 ? 12 1 2 3 1 10 7 4 2 ? 9 1 4 ? 7 0 2 0 8 1 5 ? 5 3 1 4 0 4 ? 1 ? 4 1 1 2 ?
输出 #1
3 2 4 6 1 11 4 3 5 7 9 3 2 3 5 1 3
Below is an illustration of three throws for the first test case. The arrows denote possible throw directions. Players who could have the ball after the throw are highlighted in gray.
  
  
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted