交流

#include <stdio.h>
#define NUM 110

int main()
{
    int a[NUM][NUM];//输入的数组
    int b[NUM];//用来保存完好的车的位置
    int i,j,n,count=0,result;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        for(j=1; j<=n; j++)
            scanf("%d",&a[i][j]);
    for(i=1; i<=n; i++)
    {
        result=1;
        for(j=1; j<=n; j++)
        {

            if(a[i][j]==1||a[i][j]==3)
            {
                result=0;
            }

        }
        if(result==1)
        {
            b[count]=i;
            count++;
        }

    }
    printf("%d\n",count);
    for(i=0; i<count; i++)
        printf("%d ",b[i]);
    return 0;
}
这道题网上类似代码很多,而且我这个还超时,是不是换成c++就好了。这道题在“1”和“3”时车一定损坏。而且“2”对应“1”,也就是说之前“1”损坏的下次碰撞另一个
车必定完好无损,所以“2”不需要计算了。我们需要定义一个数组来存没损坏车的位置,还需要一个计数器保存没损坏车的数量。感觉自己英语水平一般,读题浪费了大量时间
日后慢慢积累,希望大家给我比较效率的建议。

Description

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?

Input

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 Aij = 1, then Aji = 2, if Aij = 3, then Aji = 3, and if Aij = 0, then Aji = 0.

Output

Print the number of good cars and in the next line print their space-separated indices in the increasing order.

Sample Input

Input
3
-1 0 0
0 -1 1
0 2 -1
Output
2
1 3 
Input
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
Output
0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值