hbmy周赛1--D

D - Toy Cars

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

Submit Status

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;
}

时间: 2024-10-25 22:00:23

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

hbmy周赛1--C

C - Exam Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description An exam for n students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects

hbmy周赛1--E

E - Combination Lock Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Description Scrooge McDuck keeps his most treasured savings in a home safe with a combination lock. Each time he wants to put there the t

HLJU周赛5解题报告

Problem A: 求第K大数 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 81  Solved: 32 [Submit][Status][Web Board] [Edit] [TestData] Description 一天,喜欢看电影的DoubleQ 和 XXZ 来到一个神奇的电影院,这个电影院可以同时放映n部电影,每部电影都有相应的票价xi,面对着杀破狼2,侏罗纪世界,少年班等等好看的电影,他们最后商量,看票价第K大的电影,但是由于电影

CSDN 轻松周赛赛题:能否被8整除

轻松周赛赛题:能否被8整除 题目详情 给定一个非负整数,问能否重排它的全部数字,使得重排后的数能被8整除. 输入格式: 多组数据,每组数据是一个非负整数.非负整数的位数不超过10000位. 输出格式 每组数据输出一行,YES或者NO,表示能否重排它的全部数字得到能被8整除的数.注意: 重排可以让0开头. 答题说明 输入样例   610 122 输出样例   YES NO 解释   第一个数可以变为016 , 160 解题:很水的一道题...思路很简单,1000是能被8整除的,所以一千的倍数都能被

2015 年 JXNU_ACS 算法组寒假第二次周赛

2015 年 JXNU_ACS 算法组寒假第二次周赛 比赛链接:http://acm.hdu.edu.cn/diy/contest_show.php?cid=26246 Start Time : 2015-02-01 13:00:00 End Time : 2015-02-01 17:30:00 终榜:http://acm.hdu.edu.cn/diy/contest_ranklist.php?cid=26246&page=1 这次比赛考查的知识都很基础,甚至还有几道就是C语言基础(比如1006

周赛 POJ 2250 Compromise

Description In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be fulfilled, and this is not a trivial task for the countries (maybe except for Luxembourg). To enforce that Germa

周赛 POJ 3934 Queue

Description Linda is a teacher in ACM kindergarten. She is in charge of n kids. Because the dinning hall is a little bit far away from the classroom, those n kids have to walk in line to the dinning hall every day. When they are walking in line, if a

周赛 POJ 3546 The Dragon of Loowater

Description Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predators, the geese populati

周赛 POJ 2245 Lotto

Description In the German Lotto you have to select 6 numbers from the set {1,2,...,49}. A popular strategy to play Lotto - although it doesn't increase your chance of winning - is to select a subset S containing k (k > 6) of these 49 numbers, and the