CodeForces - 545A Toy Cars (模拟)
来源:互联网 发布:淘宝店铺招牌模板 编辑:程序博客网 时间:2024/05/22 06:44
【题目链接】:click here~~
【题目大意】:
给一个n*n的矩阵,-1只在对角线出现(因为自己不能撞自己),0代表没有车在碰撞,1代表第i辆车(横坐标)被撞坏了,2代表第j辆车(纵坐标)被撞坏了,3代表两辆车都撞坏了。问哪几辆车完好无损。
代码:
/* * Problem: CodeForces - 545A * Running time: 15MS * Complier: G++ * Author: herongwei * Create Time: 7:47 2015/9/17 星期四*统计每行1和3的个数,如果二者只要有其中之一,车就意味着坏了*/ #include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>using namespace std;typedef long long LL;const int N=1e5+100;const int inf=0x7f7f7f7f;bool ok[N];int main(){ int t,n,m; memset(ok,false,sizeof(ok)); scanf("%d",&t); for(int i=1; i<=t; ++i){ for(int j=1; j<=t; ++j){ int x; scanf("%d",&x); if(x==1||x==3) ok[i]=true; } } int ans=0; for(int i=1; i<=t; ++i){ if(!ok[i]) ans++; } printf("%d\n",ans); for(int i=1; i<=t; ++i){ if(!ok[i]) printf("%d ",i); } if(ans) puts(""); return 0;}
1 0
- CodeForces - 545A Toy Cars (模拟)
- Codeforces Round #303 (Div.2)-A. Toy Cars(模拟)
- CodeForces 303A Toy Cars
- codeforces #303 div2 A. Toy Cars
- Codeforces Round #303 A. Toy Cars
- A. Toy Cars
- A. Toy Cars
- contest: Codeforces Round #303 (Div. 2), problem: (A) Toy Cars
- Toy Cars (周赛2)
- (模拟)Codeforces Round #426 A. The Useless Toy
- Codeforces 84A:Toy Army(水题)
- CodeForces 605 A.Sorting Railway Cars(贪心)
- CodeForces 84. A Toy Army
- Codeforces 84A:Toy Army
- Codeforces 84A Toy Army
- 周赛-Toy Cars
- CodeForces 834 A.The Useless Toy(水~)
- Sorting Railway Cars----CodeForces 605A
- android端读取本地图片出现OutOfMemoryException
- LeetCode-First Bad Version
- 数据结构之循环数组实现队列
- 打印机正在打印出错
- 用NetBeNetBeans
- CodeForces - 545A Toy Cars (模拟)
- SendAnywhere 跨平台传输文件(推荐)
- 详解Android中AsyncTask的使用
- 核心动画基础动画
- CodeForces 545CWoodcutters (贪心orDP)
- 【1】基于ATmega 8A -PU 的蓝牙遥控电源插座设计——【1、总体方案设计】
- Codeforces Round #320 div2 题解
- CodeForces 545BEquidistant String (模拟)
- 一元兑换问题