Toy Cars

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 test(s)

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

水题一道,暴力即可

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define eps 1e-9
#define LL long long
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define CRR fclose(stdin)
#define CWW fclose(stdout)
#define RR freopen("input.txt","r",stdin)
#pragma comment(linker,"/STACK:102400000")
#define WW freopen("output.txt","w",stdout) const int Max = 1e5; int a[110][110]; int n; int b[110]; int num; int main()
{
scanf("%d",&n);
num=0;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=n; j++)
{
scanf("%d",&a[i][j]);
}
}
int i,j;
for(i=1; i<=n; i++)
{
for(j=1; j<=n; j++)
{
if(a[i][j]==0||a[i][j]==-1||a[i][j]==2)
{
continue;
}
if(a[i][j]==3||a[i][j]==1)
{
break;
}
}
if(j>n)
{
b[num++]=i;
}
}
if(num)
{
printf("%d\n",num);
for(i=0; i<num; i++)
{
if(i)
printf(" ");
printf("%d",b[i]);
}
printf("\n");
}
else
{
printf("0\n");
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

周赛-Toy Cars 分类: 比赛 2015-08-08 15:41 5人阅读 评论(0) 收藏的更多相关文章

  1. SQL 分组 加列 加自编号 自编号限定 分类: SQL Server 2014-11-25 15:41 283人阅读 评论(0) 收藏

    说明: (1)日期以年月形式显示:convert(varchar(7),字段名,120) , (2)加一列 (3)自编号: row_number() over(order by 字段名 desc) a ...

  2. Find The Multiple 分类: 搜索 POJ 2015-08-09 15:19 3人阅读 评论(0) 收藏

    Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21851 Accepted: 8984 Sp ...

  3. Ultra-QuickSort 分类: POJ 排序 2015-08-03 15:39 2人阅读 评论(0) 收藏

    Ultra-QuickSort Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 48111   Accepted: 17549 ...

  4. Drainage Ditches 分类: POJ 图论 2015-07-29 15:01 7人阅读 评论(0) 收藏

    Drainage Ditches Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 62016 Accepted: 23808 De ...

  5. cf 61E. Enemy is weak 树状数组求逆序数(WA) 分类: Brush Mode 2014-10-19 15:16 104人阅读 评论(0) 收藏

    #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> ...

  6. max_flow(Dinic) 分类: ACM TYPE 2014-09-02 15:42 94人阅读 评论(0) 收藏

    #include <cstdio> #include <iostream> #include <cstring> #include<queue> #in ...

  7. C#多线程(下) 分类: C# 线程 2015-03-09 10:41 153人阅读 评论(0) 收藏

    四.多线程的自动管理(线程池) 在多线程的程序中,经常会出现两种情况: 一种情况: 应用程序中,线程把大部分的时间花费在等待状态,等待某个事件发生,然后才能给予响应 这一般使用ThreadPool(线 ...

  8. SQL 按月统计(两种方式) 分类: SQL Server 2014-08-04 15:36 154人阅读 评论(0) 收藏

    (1)Convert 函数 select Convert ( VARCHAR(7),ComeDate,120) as Date ,Count(In_code) as 单数,Sum(SumTrueNum ...

  9. SQL 存储过程 分页 分类: SQL Server 2014-05-16 15:11 449人阅读 评论(0) 收藏

    set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go -- ============================================= -- Au ...

随机推荐

  1. VVDocumenter 注释工具的使用

    首先,前往github上下载工程源代码. 然后,编译VVDocumenter工程. 重启xcode. 然后,只要在你自己的工程中要加入注释的方法前面输入“///”,一切搞定. 很好很强大.

  2. bash 截取字符串

    转载自http://blog.chinaunix.net/uid-1757778-id-3162034.html 命令的2种替换形式 $()和 ``示例:截断字符串    a):    #截取文件名称 ...

  3. linux 命令之 insmod

    man insmod: INSMOD(8) insmod INSMOD(8) NAME insmod - Simple program to insert a module into the Linu ...

  4. SQL 数据库 存储过程 视图

    一.存储过程 1.概述 存储过程是一组编译在单个执行计划中的T-SQL语句 存储过程:就像函数一样的会保存在数据库中(可编程性) 存储过程的优点: 1.允许模块化程序设计 2.允许更快执行如果某操作需 ...

  5. Aspectj是什么

    转载自:http://www.cnblogs.com/sunwke/articles/2568875.html 网上出现了很多讲解 AspectJ 的资料,但大多是从讲解 AspectJ 语法开始,然 ...

  6. POJ 2947 Widget Factory(高斯消元)

    Description The widget factory produces several different kinds of widgets. Each widget is carefully ...

  7. java jdbc数据库操作

    package shb.java.demo3; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQ ...

  8. Envelope对象介绍

    Envelope也称包络线,是一个矩形区域,是每个几何形体的最小外接矩形.每个Geometry都拥有一个Envelope,包括Envelope自身. 它定义了XMax,XMin,YMax,YMin,H ...

  9. oracle冷备份后恢复

    本地恢复 在运行中输入cmd. 在cmd界面中输入sqlplus/nolog进入sql*plus. 以dba身份连接数据库conn sys/你设定的密码 as sysdba. 输入:shutdown ...

  10. android studio1.0 for Mac环境搭建与demo运行(手动下载gradle,科学上google) 转载

    http://blog.csdn.net/allenffl/article/details/41957907 官网下载 http://developer.android.com/sdk/install ...