D - Toy Cars

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

#include <iostream>
using namespace std; int main()
{
int a[110][110], b[110], c[110], d[110];
for (int i=0; i<110; i++)
{
b[i] = 0;
c[i] = 0;
d[i] = 0;
}
int n;
cin >> n;
for (int i=0; i<n; i++)
{
for (int j=0; j<n; j++)
{
cin >> a[i][j];
}
}
for (int i=0; i<n; i++)
{
for (int j=0; j<n; j++)
{
if (a[i][j] == 1)
b[i] = 1;
if (a[i][j] == 2)
c[j] = 1;
if (a[i][j] == 3)
{
b[i] = 1;
c[j] = 1;
}
}
}
int result=0;
int num = 0;
for (int i=0; i<n; i++)
{
if (b[i]==c[i] && b[i]==0)
{
d[num++] = i;
result++;
}
}
cout << result << endl;
if (num>0)
{
cout << d[0]+1;
for (int i=1; i<num; i++)
cout << " "<< d[i]+1;
cout << endl;
}
return 0;
}

hbmy周赛1--D的更多相关文章

  1. hbmy周赛1--E

    E - Combination Lock Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I6 ...

  2. hbmy周赛1--C

    C - Exam Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit St ...

  3. hbmy周赛1--B

    B - 改革春风吹满地 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit  ...

  4. hbmy周赛1--A

    Age Sort You are given the ages (in years) of all people of a country with at least 1 year of age. Y ...

  5. 周赛-KIDx's Pagination 分类: 比赛 2015-08-02 08:23 7人阅读 评论(0) 收藏

    KIDx's Pagination Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) S ...

  6. 2015浙江财经大学ACM有奖周赛(一) 题解报告

    2015浙江财经大学ACM有奖周赛(一) 题解报告 命题:丽丽&&黑鸡 这是命题者原话. 题目涉及的知识面比较广泛,有深度优先搜索.广度优先搜索.数学题.几何题.贪心算法.枚举.二进制 ...

  7. Leetcode 第133场周赛解题报告

    今天参加了leetcode的周赛,算法比赛,要求速度比较快.有思路就立马启动,不会纠结是否有更好的方法或代码可读性.只要在算法复杂度数量级内,基本上是怎么实现快速就怎么来了. 比赛时先看的第二题,一看 ...

  8. 牛客OI周赛9-提高组题目记录

    牛客OI周赛9-提高组题目记录 昨天晚上做了这一套比赛,觉得题目质量挺高,而且有一些非常有趣而且非常清奇的脑回路在里边,于是记录在此. T1: 扫雷 题目链接 设 \(f_i\) 表示扫到第 \(i\ ...

  9. codeforces 14A - Letter & codeforces 859B - Lazy Security Guard - [周赛水题]

    就像title说的,是昨天(2017/9/17)周赛的两道水题…… 题目链接:http://codeforces.com/problemset/problem/14/A time limit per ...

随机推荐

  1. 我与 windows kernel 的一段时光

    写在前面 本科毕业设计是实现一个基于 windows 的透明加密过滤系统.由此对 windows kernel development,尤其是 file system 进行过较为深入的探索.对于防终止 ...

  2. dataGrideView的使用

    总的连接地址:http://group.cnblogs.com/topic/40730.html 微软解说:https://msdn.microsoft.com/zh-cn/library/syste ...

  3. 绝世emacs配置for Ubuntu

    反正过不了几天就要退役了,把emacs配置放出来造福(祸害)大众? 浓浓的OIER风格,除了方便打代码就没别的用处(F8并不这样认为?),只可惜windows下的弄丢了,只有Ubuntu下的. F1不 ...

  4. bzoj 3139: [Hnoi2013]比赛

    Description 沫沫非常喜欢看足球赛,但因为沉迷于射箭游戏,错过了最近的一次足球联赛.此次联 赛共N支球队参加,比赛规则如下: (1) 每两支球队之间踢一场比赛. (2) 若平局,两支球队各得 ...

  5. Cat 客户端如何构建调用链消息树

    场景 & 代码 Inner0 中的某方法调用了 Inner1,代码 Inner1的代码很简单, Cat通过一个线程本地变量来保存调用链的相关信息,其中核心的数据结构是消息树和操作栈.消息树用来 ...

  6. override与重载(overload)的区别

    重载是相同函数名字.参数或参数类型不同,进行多次承载以适应不同的需要.(orerload)是面向过程的重载. (override)是面向对象的重载.是进行基类中的函数重写.

  7. 视觉SLAM的方案总结

    MoNoSLAM:https://github.com/hanmekim/SceneLib2 以扩展卡尔曼滤波为后端,追踪前端非常稀疏的特征点,以相机的当前状态和所有路标点为状态量,更新其均值和协方差 ...

  8. asp.net MVC里的 ModelState使用方法

    https://www.cnblogs.com/hohoa/p/5839993.html if (!ModelState.IsValid) { string error = string.Empty; ...

  9. PCA主成份分析

    1   背景介绍 真实的训练数据总是存在各种各样的问题: 1. 比如拿到一个汽车的样本,里面既有以“千米/每小时”度量的最大速度特征,也有“英里/小时”的最大速度特征,显然这两个特征有一个多余. 2. ...

  10. icon图标和文字整体居中在button按钮

    icon图标和文字整体居中在button按钮 icon图标和文字整体居中 一般我们常做的button按钮是文字居中 现在这个需要icon图标和文字一起居中在背景色 <a href="# ...