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 ...
随机推荐
- elasticsearch插件之一:marvel
在 安装插件的过程中,尤其是安装Marvel插件遇到了很多问题,又要下载license.Marvel-agent,又要下载安装Kibana,很多内容 不知道为何这样安装处理.仔细看了看ElasticS ...
- Prime Palindromes
题目大意:求出区间[a,b]之间的回文质数. a<=b<=10^8; 解题过程: 1.先打个素数表,新学了个 欧拉筛法,是对普通筛法的改进.普通筛法是每找到一个素数,就把它的所有倍数标记成 ...
- DataGridView的按钮列的点击事件
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { ) { DataGr ...
- mac 下隐藏和显示文件
显示:defaults write com.apple.finder AppleShowAllFiles -bool true隐藏:defaults write com.apple.finder Ap ...
- python处理url中的中文编码,以及其他编码问题
1.python中的urlencode与urldecode 2.各种编码转换在线工具 3.python用于url解码和中文解析的小脚本(python url decoder) 4.如何只对url中的中 ...
- jQuery初步
1.jQuery开发步骤 jQuery是第三方开源组织基于js写的一款跨主流浏览器的实用库. (1)引用第三方js库文件,<script type="text/javascript&q ...
- 多功能节点连线绘图控件Nevron Diagram for .NET使用方法及下载地址
Nevron Diagram for .NET是一个功能强大,世界上顶级的.NET图表控件.可扩展的图形报表构架,可以帮您创建功能丰富的Winforms及Webforms图表解决方案.这个产品构建于N ...
- iframe中的jquery ui modal dialog 覆盖父窗口
在iframe中 使用jquery ui dialog,弹出后可以覆盖父窗体 ///iframe中的jquery ui modal dialog 覆盖父窗口 function openDialog() ...
- c++形参和实参同名时,如何单步执行观察形参的变化。
c++形参和实参同名时,如何单步执行观察形参的变化? 方法:当程序运行到函数中时,添加变量观察即可.
- hdoj-2023
#include "stdio.h"int main(){ int a[55][6]; double pingjun[55],mk[6]; int n,m,i,j,sum=0,co ...