CF545A.Toy Cars
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Little Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament between them. The process of a tournament is described in the next paragraph.
There are n toy cars. Each pair collides. The result of a collision can be one of the following: no car turned over, one car turned over, both cars turned over. A car is good if it turned over in no collision. The results of the collisions are determined by an n × n matrix А: there is a number on the intersection of the і-th row and j-th column that describes the result of the collision of the і-th and the j-th car:
- - 1: if this pair of cars never collided. - 1 occurs only on the main diagonal of the matrix.
- 0: if no car turned over during the collision.
- 1: if only the i-th car turned over during the collision.
- 2: if only the j-th car turned over during the collision.
- 3: if both cars turned over during the collision.
Susie wants to find all the good cars. She quickly determined which cars are good. Can you cope with the task?
小苏西在她哥哥的帮助下,喜欢玩小汽车。今天,她决定为这些小汽车举办一场锦标赛。锦标赛的过程如下所述。
共有 n 辆玩具小汽车。每一对小汽车都会发生一次碰撞。每次碰撞的结果可能是以下三种情况之一:没有小汽车翻倒、仅一辆小汽车翻倒、两辆小汽车均翻倒。若一辆小汽车在所有碰撞中均未翻倒,则称其为“好车”。各次碰撞的结果由一个 n×n 矩阵 A 给出:矩阵中第 i 行第 j 列的元素描述了第 i 辆与第 j 辆小汽车之间的碰撞结果:
- −1:表示该对小汽车从未发生碰撞;−1 仅出现在矩阵的主对角线上;
- 0:表示此次碰撞中没有小汽车翻倒;
- 1:表示此次碰撞中仅第 i 辆小汽车翻倒;
- 2:表示此次碰撞中仅第 j 辆小汽车翻倒;
- 3:表示此次碰撞中两辆小汽车均翻倒。
小苏西希望找出所有“好车”。她已迅速确定了哪些小汽车是好车。你能否完成这项任务?
输入格式
The first line contains integer n (1 ≤ n ≤ 100) — the number of cars.
Each of the next n lines contains n space-separated integers that determine matrix A.
It is guaranteed that on the main diagonal there are - 1, and - 1 doesn't appear anywhere else in the matrix.
It is guaranteed that the input is correct, that is, if A__ij = 1, then A__ji = 2, if A__ij = 3, then A__ji = 3, and if A__ij = 0, then A__ji = 0.
第一行包含一个整数 n(1≤n≤100)—— 表示汽车的数量。
接下来的 n 行,每行包含 n 个用空格分隔的整数,用于确定矩阵 A。
保证主对角线上的元素均为 −1,且 −1 不在矩阵的其他任何位置出现。
保证输入是合法的,即:若 Aij=1,则 Aji=2;若 Aij=3,则 Aji=3;若 Aij=0,则 Aji=0。
输出格式
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
输出好车的数量,下一行按升序输出它们以空格分隔的索引。
输入输出样例
输入#1
3 -1 0 0 0 -1 1 0 2 -1
输出#1
2 1 3
输入#2
4 -1 3 3 3 3 -1 3 3 3 3 -1 3 3 3 3 -1
输出#2
0
输入解题思路,AI测评打分。不知道怎么写?