Codeforces Round #303 (Div. 2) A 水
1 second
256 megabytes
standard input
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?
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.
Print the number of good cars and in the next line print their space-separated indices in the increasing order.
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 题意:给你一个矩阵 描述n辆车之间的关系
0 代表碰撞中都不会翻车
1 代表碰撞中i翻车
2 代表碰撞中j翻车
3 代表碰撞中两辆车都翻车 求在什么情况下都不会翻车的车的数量并输出序号
题解:模拟 把行列代表的车标记一下就可以了
/******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<map>
#include<algorithm>
#include<queue>
#include<cmath>
#define ll __int64
#define PI acos(-1.0)
#define mod 1000000007
using namespace std;
int n;
int exm;
int a[];
int main()
{
scanf("%d",&n);
memset(a,,sizeof(a));
for(int i=; i<=n; i++)
{
for(int j=; j<=n; j++)
{
scanf("%d",&exm);
if(exm==)
a[i]=;
if(exm==)
a[j]=;
if(exm==)
{
a[i]=;
a[j]=;
}
}
}
int ans=;
for(int i=; i<=n; i++)
{
if(a[i]==)
ans++;
}
cout<<ans<<endl;
for(int i=; i<=n; i++)
{
if(a[i]==)
cout<<i<<" ";
}
cout<<endl;
return ;
}
Codeforces Round #303 (Div. 2) A 水的更多相关文章
- Codeforces Round #303 (Div. 2) B 水 贪心
B. Equidistant String time limit per test 1 second memory limit per test 256 megabytes input standar ...
- 水题 Codeforces Round #303 (Div. 2) D. Queue
题目传送门 /* 比C还水... */ #include <cstdio> #include <algorithm> #include <cstring> #inc ...
- 水题 Codeforces Round #303 (Div. 2) A. Toy Cars
题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...
- DP Codeforces Round #303 (Div. 2) C. Woodcutters
题目传送门 /* 题意:每棵树给出坐标和高度,可以往左右倒,也可以不倒 问最多能砍到多少棵树 DP:dp[i][0/1/2] 表示到了第i棵树时,它倒左或右或不动能倒多少棵树 分情况讨论,若符合就取最 ...
- 贪心 Codeforces Round #303 (Div. 2) B. Equidistant String
题目传送门 /* 题意:找到一个字符串p,使得它和s,t的不同的总个数相同 贪心:假设p与s相同,奇偶变换赋值,当是偶数,则有答案 */ #include <cstdio> #includ ...
- Codeforces Round #303 (Div. 2) B. Equidistant String 水题
B. Equidistant String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/54 ...
- Codeforces Round #303 (Div. 2) A. Toy Cars 水题
A. Toy Cars Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/problem ...
- Codeforces Round #303 (Div. 2) D. Queue 水题贪心
题目: 题意:给你n个数值,要求排列这个序列使得第k个数值的前K-1个数的和>=第k个数值的个数尽可能多: #include <iostream> #include <cstd ...
- Codeforces Round #365 (Div. 2) A 水
A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ...
随机推荐
- Servlet作业--实现注册和登录
1.注册页面 zhuce.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " ...
- poj题目必做
OJ上的一些水题(可用来练手和增加自信) (poj3299T,poj2159T,poj2739T,poj1083T,poj2262T,poj1503T,poj3006T,poj2255T,poj309 ...
- hdu 4612 Warm up
http://acm.hdu.edu.cn/showproblem.php?pid=4612 将原图进行缩点 变成一个树 树上每条边都是一个桥 然后加一条边要加在树的直径两端才最优 代码: #incl ...
- TOP 10开源的推荐系统简介
最近这两年推荐系统特别火,本文搜集整理了一些比较好的开源推荐系统,即有轻量级的适用于做研究的SVDFeature.LibMF.LibFM等,也有重量级的适用于工业系统的 Mahout.Oryx.Eas ...
- FG模型
一直没搞懂CvBGStatModel和CvFGDStatModel有什么区别.CvBGStatModel模型的创建用cvCreateGaussianBGModel,CvFGDStatModel模型的创 ...
- HDU 3336 扩展kmp
题目大意: 找到字符串中所有和前缀字符串相同的子串的个数 对于这种前缀的问题,通常通过扩展kmp来解决 其实吧这是我第一次做扩展kmp的题目,原来确实看过这个概念,今天突然做到,所以这个扩展kmp的模 ...
- HTTPS Everywhere – 保障隐私和信息安全的利器
HTTPS Everywhere 是一款 Chrome 扩展程序,对于支持 HTTPS 的网站默认打开 HTTPS 加密传输来保障信息安全(HTTPS 介绍). HTTPS Everywhere 受到 ...
- SharePoint 2013 开发——概述
博客地址:http://blog.csdn.net/FoxDave 近来阅读SharePoint 2013开发一书,带着与大家一起分享其中的内容. 部署场景: 本地部署(On-Premise D ...
- SharePoint开发 - 使用Session(代码修改webconfig)
博客地址 http://blog.csdn.net/foxdave SharePoint启用Session可以使用Powershell,戳这里:可以修改webconfig. 本篇叙述的重点是通过fea ...
- Mac下的SVN客户端工具Cornerstone使用教程
前面几篇文章我介绍SVN服务器的安装,配置,实战.当然其中也加入了一些客户端测试的命令,使用命令当然是一个非常好的选择,但是对我们人类来说还是喜欢图形化界面的操作的.因此本文将介绍我喜欢的一款SVN客 ...