hbmy周赛1--D
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
3
-1 0 0
0 -1 1
0 2 -1
2
1 3
4
-1 3 3 3
3 -1 3 3
3 3 -1 3
3 3 3 -1
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的更多相关文章
- hbmy周赛1--E
E - Combination Lock Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I6 ...
- hbmy周赛1--C
C - Exam Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit St ...
- hbmy周赛1--B
B - 改革春风吹满地 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- 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 ...
- 周赛-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 ...
- 2015浙江财经大学ACM有奖周赛(一) 题解报告
2015浙江财经大学ACM有奖周赛(一) 题解报告 命题:丽丽&&黑鸡 这是命题者原话. 题目涉及的知识面比较广泛,有深度优先搜索.广度优先搜索.数学题.几何题.贪心算法.枚举.二进制 ...
- Leetcode 第133场周赛解题报告
今天参加了leetcode的周赛,算法比赛,要求速度比较快.有思路就立马启动,不会纠结是否有更好的方法或代码可读性.只要在算法复杂度数量级内,基本上是怎么实现快速就怎么来了. 比赛时先看的第二题,一看 ...
- 牛客OI周赛9-提高组题目记录
牛客OI周赛9-提高组题目记录 昨天晚上做了这一套比赛,觉得题目质量挺高,而且有一些非常有趣而且非常清奇的脑回路在里边,于是记录在此. T1: 扫雷 题目链接 设 \(f_i\) 表示扫到第 \(i\ ...
- codeforces 14A - Letter & codeforces 859B - Lazy Security Guard - [周赛水题]
就像title说的,是昨天(2017/9/17)周赛的两道水题…… 题目链接:http://codeforces.com/problemset/problem/14/A time limit per ...
随机推荐
- Kotlin——最详细的数据类、密封类详解
在前面几个章节章节中,详细的讲解了Koltin中的接口类(Interface).枚举类(Enmu),还不甚了解的可以查看我的上一篇文章Kotlin--接口类.枚举类详解.当然,在Koltin中,除了接 ...
- ArcGIS API for JavaScript 4.2学习笔记[18] 搜索小部件
这个例子很简单,作为开学后(暴露出学生党的本质)的开胃菜是再合适不过了. 不过,博主提前警告一下:接下来的例子会相当的长.烦.难.我还会用"引用"-"函数参数骨架&quo ...
- 优化设计提高sql类数据库的性能
前言 在一个项目中,技术的统一性是最重要的,数据库的设计则是重点中的重点.NoSQL 是目前最流行的数据库,但是其实用性和功能性远不如sql数据库. 实际很多SQL数据库被诟病的性能问题大多是源于程序 ...
- Xamarin调用JSON.net来解析JSON
https://www.cnblogs.com/zjoch/p/4458516.html 再来我们要怎么解析JSON格示呢?在.net 中,我们很孰悉的JSON.net,没错,我们依然可以在X ...
- 鸟哥的linux私房菜学习-(四)linux命令的基本概念
一.命令格式及使用方式 注意到上面的说明当中,『第一个被输入的数据绝对是命令或者是可运行的文件』! 这个是很重要的概念喔!还有,按下[Enter]键表示要开始运行此一命令的意思. 如下效果一样: 二. ...
- Numpy
一 : 安装ipython以及用到的包介绍 # 这里我们会用到ipython解释器,本文代码在ipython下运行 Pip3 install ipython Pip3 install jupyter ...
- 数组a[n]中存放1-n中的n-1个数,给出算法找出重复的那一个数
问题描述: 数组a[n]中存放1-n中的n-1个数,给出算法找出重复的那一个数. 算法一: 对数组a[n]进行冒泡排序,如果冒泡所得的最值和前一个最值相等,则该最值为重复的数. 分析: 该算法时间复杂 ...
- 自动化测试-Selenium家谱介绍
一.自动化测试定义 自动化测试是通工具录制或编写脚本的方式模拟手工测试的过程,通过回放或运行脚本来执行测试用例,从而代替人工对系统的功能进行验证. 二.什么样的项目适合做自动化测试 1.需求明确,不会 ...
- JS函数的参数声明中用 var 与不用 var的区别
1.var 声明的变量,作用域是当前 function 2.没有声明的变量,直接赋值的话, 会自动创建变量,但作用域是全局的. 例如: function doSth() { a = "AAA ...
- KandQ:那年,那树,那些知识点
写在前面: 对于数据结构的学习,注定绕不开"树"这一起着重要作用的数据结构."树"在整个数据结构的学习过程中具有举足轻重的地位,而与"树" ...