A. Toy Cars
来源:互联网 发布:centos查看防火墙端口 编辑:程序博客网 时间:2024/06/06 01:03
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?
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, thenAji = 0.
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
3-1 0 00 -1 10 2 -1
21 3
4-1 3 3 33 -1 3 33 3 -1 33 3 3 -1
0
解题说明:此题是一道模拟题,只需要判断出现1和出现3的情况,并把相应行所代表的玩具车进行标记,最后进行输出。
#include <stdio.h>int main(){int i,j,n,dl[101][101],kq[101],kq1[101],t=0;scanf("%d",&n);for(i=1;i<=n;i++){for(j=1;j<=n;j++){scanf("%d",&dl[i][j]);if(dl[i][j]==1){kq[i]=1;}if(dl[i][j]==3){kq[i]=1;}}}for(i=1;i<=n;i++){if(kq[i]==0){t++;kq1[t]=i;}}printf("%d\n",t);for(i=1;i<=t;i++){printf("%d ",kq1[i]);}return 0;}
- A. Toy Cars
- A. Toy Cars
- CodeForces 303A Toy Cars
- codeforces #303 div2 A. Toy Cars
- Codeforces Round #303 A. Toy Cars
- CodeForces - 545A Toy Cars (模拟)
- contest: Codeforces Round #303 (Div. 2), problem: (A) Toy Cars
- Codeforces Round #303 (Div.2)-A. Toy Cars(模拟)
- 周赛-Toy Cars
- Toy Cars (周赛2)
- BOZJ1528/POI 2005Toy Cars
- 【bzoj1528】 [POI2005]sam-Toy Cars
- 【bzoj1528】[POI2005]sam-Toy Cars
- bzoj 1528: [POI2005]sam-Toy Cars
- [bzoj1528/POI2005]sam-Toy Cars---贪心+堆
- BZOJ 1528 POI2005 sam-Toy Cars 堆+贪心
- 【BZOJ 1528】[POI2005]sam-Toy Cars 贪心+堆
- A. Toy Army
- IOS实现多媒体音频之音乐播放器
- 数据结构与算法(单循环链表)
- 垃圾回收的finalize方法使用
- HDOJ 寻找素数对 1262
- leetcode 日经贴,Cpp code -Maximal Square
- A. Toy Cars
- 魔狼地址:https://bitbucket.org/moLangZaiShi/demo/downloads
- 百度地图SDK 详解 应用(官方)
- 垃圾收集算法
- Oracle学习(十一)之使用RMAN对数据库做在线完全备份
- gdb调试ns3出现的问题-找不到库
- ios一些关键字
- MFC:判断点(POINT)是否在某一区域(CRect)
- google访问