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. PostgreSQL中字符串相关问题

    PostgreSQL的字符串类型有character.character varying和text的值.在使用character类型的时候, 它有自动填充空白的潜在影响,特别是在其它数据库(MySQL ...

  2. Linux的set

    功能说明: 设置shell 语 法: set [+-abCdefhHklmnpPtuvx] 补充说明: set指令能设置所使用shell的执行方式,可依照不同的需求来做设置. 参 数: -a 标示已修 ...

  3. javax.servlet.jsp.JspException cannot be resolved to a type

    javax.servlet.jsp.PageContext cannot be resolved to a type javax.servlet.jsp.JspException cannot be ...

  4. JSon_零基础_002_将List类型数组转换为JSon格式的对象字符串,返回给界面

    将List类型数组转换为JSon格式的对象字符串,返回给界面 所需要导入的包: 编写bean: package com.west.webcourse.po; /** * 第01步:编写bean类, * ...

  5. CSS_03_04_CSS伪元素选择器

    第01步:编写css代码:wei.css @charset "utf-8"; /* 伪元素选择器 :状态 效果顺序:L V H A */ a:link.lin_01{/*超链接,未 ...

  6. RMAN备份演练进阶篇

    前篇介绍了通过rman进行各种备份,进阶篇则主要是rman的一些功能扩展和增加功能,利用前篇你已经完全可以完成数据库的备份,而通过本篇你可以更好更方便的完成数据库的备份. 一.建立增量备份 如果数据库 ...

  7. 夺命雷公狗---node.js---21之项目的构建在node+express+mongo的博客项目6之数据的遍历

    首先还是来链接数据库,然后就查找,如下所示: /** * Created by leigood on 2016/8/31. */ var express = require('express'); v ...

  8. zw版【转发·台湾nvp系列Delphi例程】HALCON SmoothImage

    zw版[转发·台湾nvp系列Delphi例程]HALCON SmoothImage procedure TForm1.Button1Click(Sender: TObject);var image0, ...

  9. ASP.NET MVC 返回JsonResult序列化内容超出最大限制报错的解决办法

    在使用MVC的时候我们经常会在Controller的Action方法中返回JsonResult对象,但是有时候你如果序列化的对象太大会导致JsonResult从Controller的Action返回后 ...

  10. SQL 基础语法(创建表空间、用户、并授予权限、数据的增删改查) --(学习笔记)[转]

    --创建表空间 名:lyayzh_test create tablespace lyayzh_test --创建表数据文件 名:lyayzh_test_data.dbf 必须以dbf为后缀 dataf ...