Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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

题意:

共有n辆车互相碰撞,表现为一个n*n的矩阵,矩阵的对角线为-1表示自己对自己。行和列分别表示为i-th和j-th,当(i-th,j-th)为1时表示i-th翻车,2时表示j-th翻车,3

时表示两车全部翻车。0表示没有车翻车。只要没有翻过的车就是好车。

思路:

对于每行扫描,当出现1/3时,就说明翻过车。

附AC代码:

 #include<iostream>
#include<vector>
using namespace std; int a[][];
vector<int> v; //用一个vector容器来储存好车 int main(){
int n;
cin>>n;
for(int i=;i<=n;i++){
int flag=;
for(int j=;j<=n;j++){
cin>>a[i][j];
if(a[i][j]==||a[i][j]==){
flag=;
}
}
if(flag==)
v.push_back(i);
}
int s=v.size();
cout<<s<<endl;
if(s!=){
for(int i=;i<s-;i++){
cout<<v[i]<<" ";
}
cout<<v[s-]<<endl;
} return ;
}

A - Toy Cars的更多相关文章

  1. 周赛-Toy Cars 分类: 比赛 2015-08-08 15:41 5人阅读 评论(0) 收藏

    Toy Cars time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  2. Codeforces Round #303 (Div. 2) A. Toy Cars 水题

     A. Toy Cars Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem ...

  3. 水题 Codeforces Round #303 (Div. 2) A. Toy Cars

    题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...

  4. [POI2005]Toy Cars

    题目大意: 有n种物品,地上有k个格子,p次操作. 每次操作要求将某一个指定的物品移动到任意一个格子中,同时你可以选择是否将格子中的某一个物品收起来,并消耗1的代价. 如果下达指令时,这个物品刚好在格 ...

  5. 题解 CF545A 【Toy Cars】

    题目传送门 太弱了,只能写写A题的题解 题意 给你一个 $n·n$ 的矩阵,翻车分三种情况: 如果 $a_i,_j=1$ ,记录第 $i$ 辆车 如果 $a_i,_j=2$ ,记录第 $j$ 辆车 如 ...

  6. P3419 [POI2005]SAM-Toy Cars / SP688 SAM - Toy Cars

    一道很妙的贪心题 题面 我们考虑当我们插入时会面临的两种情况 当地上的玩具,不满 \(k\) 个时,那我们直接放就可以了. 当满了 \(k\) 个的时候,我们就要从地上拿出一个来给当前的腾位置. 这就 ...

  7. [POI2005]SAM-Toy Cars

    题目描述 Johnny is a little boy - he is only three years old and enjoys playing with toy cars very much. ...

  8. bzoj1528 sam-Toy Cars(贪心,优先队列)

    「BZOJ1528」[POI2005] sam – Toy Cars Description Jasio 是一个三岁的小男孩,他最喜欢玩玩具了,他有n 个不同的玩具,它们都被放在了很高的架子上所以Ja ...

  9. 洛谷 P3419 [POI2005]SAM-Toy Cars

    P3419 [POI2005]SAM-Toy Cars 题目描述 Johnny is a little boy - he is only three years old and enjoys play ...

随机推荐

  1. http协议的Last-Modified

    $modified_time = $_SERVER['HTTP_IF_MODIFIED_SINCE']; if (strtotime($modified_time) + 3600 > time( ...

  2. jsp表达式

    能够在"<%="和"%>"之间插入一个表达式(注意:不可插入语句. "<%="是一个完整的符号,"<%&q ...

  3. Ubuntu Server 12.04 乱码

    sudo vim /etc/default/locale 将 下面的内容修改 LANG="zh_CN.UTF-8" LANGUAGE="zh_CN:zh" 修改 ...

  4. JAVA 数据筛选(第一笔数据与第二笔数据比较)

    第一笔数据与第二笔数据比较 Map<String, Object> jHpictureMap = new HashMap<String, Object>(); // 存放照片S ...

  5. redis缓冲与数据库

    redis是基于key-value结构存储的,且数据存放在内存中,相对数据库读写较快. 基于redis的优势,将redis中存放用户数据,用户第一次登录时,将用户数据从数据库存放redis中,也可以将 ...

  6. C语言预处理条件语句的 与或运算

    1.#ifdef 与或运算 #ifdef  (MIN)  && (MAX)  ----------------------------错误使用 #if  defined(MIN)  & ...

  7. NOTE:rfc5766-turn-server

    NOTE:This project is active in Google code: http://code.google.com/p/rfc5766-turn-server/ 启动方法:./tur ...

  8. cocos2d-js v3事件管理器

    总概: 1.时间监听器(cc.EventListener)封装用户的事件处理逻辑. 2.事件管理器(cc.eventManager)管理用户注册的事件监听器. 3.事件对象(cc.Event)包含事件 ...

  9. CentOS 更换 usr 挂载分区

    由于之前挂载在/usr目录的分区空间过小,无法安装更多需要的软件,现在添加一块硬盘重新挂载在/usr目录,并将之前/usr 目录下的内容(包括权限.连接等)完整拷贝到新磁盘分区的/usr目录. 操作系 ...

  10. listview 使用图片三级缓存图片闪动