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 ...
随机推荐
- 理解new构造函数和apply以及call
今天在看设计模式的时候,遇到一些挺低级的东西,搞不懂,顾查阅资料整理记录一番. 先了解一下new构造函数的过程: function func(){ console.log('do'); } var f ...
- canvas学习api
1.canvas.getContext():获取渲染上下文和绘画功能: 一.绘制矩形 2.ctx.fillRect(x,y,width,height):绘制矩形: 3.ctx.strokeRect(x ...
- 30分钟入门Java
技术只是工具,文档只是说明书,仅此而已. 写在前面 工作4年有余,盲人摸象般的走过弯路,也投机取巧的领悟到过一些类似"编程本质"的东西.现在开始我计划回顾下我的编程生涯.在这里分享 ...
- js把通过图片路径生成base64
主要思想: 使用canvas.toDataURL()方法将图片的绝对路径转换为base64编码. 一.图片在本地服务器: var imgSrc = "img/1.jpg";//本地 ...
- input上传图片(file),预览图片的两种方法。blob与base64编码
上传图片时一般都需要预览,我一般用这两种方法来实现.base64编码可以直接上传到后台,后台解析下,得到的文件就会比较小了,省去了压缩图片这一步了. //获取对象input file 的图片地址,放进 ...
- CSS 的优先级机制[总结]
样式的优先级 多重样式(Multiple Styles):如果外部样式.内部样式和内联样式同时应用于同一个元素,就是使多重样式的情况. 一般情况下,优先级如下: (外部样式)External styl ...
- 自己做一台3D打印机到底有多难?(附教程)
• 微博: 小样儿老师2015 初识 3D打印技术,即快速成形技术,它是一种以数字模型文件为基础,运用粉末状金属或塑料等可粘合材料,通过逐层打印的方式来构造物体的技术,3D打印机则出现在上世纪9 ...
- SQLServer Agent执行[分发清除: distribution] 无法删除快照文件
由于之前创建的发布订阅造成严重的性能压力,症状表现为发布订阅表查询产生CMEMTHREAD suspend等待,由于开发配置每隔十分钟会产生大量的SQLCOMMAND(create table,cr ...
- golang 轮训加密算法
Roy's friends has been spying on his text messages, so Roy thought of an algorithm to encrypt text m ...
- CSS3 Media Queries 特性的妙用
第一招: 在网页中,pixel与point比值称为 device-pixel-ratio,普通设备都是1,iPhone 4是2,有些Android机型是1.5. 那么-webkit-min-devic ...