周赛-Toy Cars
2015-08-08 15:41
274 查看
Toy Cars
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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:
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 test(s)
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
水题一道,暴力即可
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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 test(s)
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 <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <vector> #include <string> #include <cstdio> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> using namespace std; #define eps 1e-9 #define LL long long #define PI acos(-1.0) #define INF 0x3f3f3f3f #define CRR fclose(stdin) #define CWW fclose(stdout) #define RR freopen("input.txt","r",stdin) #pragma comment(linker,"/STACK:102400000") #define WW freopen("output.txt","w",stdout) const int Max = 1e5; int a[110][110]; int n; int b[110]; int num; int main() { scanf("%d",&n); num=0; for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { scanf("%d",&a[i][j]); } } int i,j; for(i=1; i<=n; i++) { for(j=1; j<=n; j++) { if(a[i][j]==0||a[i][j]==-1||a[i][j]==2) { continue; } if(a[i][j]==3||a[i][j]==1) { break; } } if(j>n) { b[num++]=i; } } if(num) { printf("%d\n",num); for(i=0; i<num; i++) { if(i) printf(" "); printf("%d",b[i]); } printf("\n"); } else { printf("0\n"); } return 0; }
相关文章推荐
- CentOS下安装Git
- ACM求经过k次移动后所得的逆序数
- 周赛-Toy Cars 分类: 比赛 2015-08-08 15:41 5人阅读 评论(0) 收藏
- Android XML文件链接错误
- JS 日期操作类
- java里的分支语句--程序运行流程的分类(顺序结构,分支结构,循环结构)
- android PhoneStateListener 内存泄露的问题
- HDOJ1856More is better (并查集)
- 什么是Java集合API?
- Android studio运行时乱码 编码问题 閿欒: 缂栫爜UTF-8鐨勪笉鍙槧灏勫瓧绗?
- java之进程理解
- WEB程序会话管理--HttpSession和Cookie
- mysql DATE_FORMAT截取时分秒
- yarn架构-Capacity Scheduler
- linux内核的冒险md来源释义# 14raid5非条块读
- (9) Cookie
- 【C语言】在终端输入多行信息,找出包含“ould”的行,并打印改行。
- django models进行数据库增删查改
- Java程序运行机制及运行过程
- 机房收费系统颗粒大归仓之----DTPicker控件与导出数据为Excel