codeforces - 738B - Spotlights (瞎搞)
来源:互联网 发布:软件测试严重程度 编辑:程序博客网 时间:2024/06/05 15:37
codeforces - 738B - Spotlights (瞎搞)
题意:
给出n*m的矩阵。其中1代表该点有演员。0代表该点可放置追光灯。
找出放置追光灯的方法数(追光灯向上下左右算4种)。
解法:
col,row记录在读到当前点之前该行/列有无演员。
最后全tm加一块就行。
#include<bits/stdc++.h>using namespace std;int maze[1010][1010];int can[1010][1010]={0};bool col[1010]={0},row[1010]={0};bool col2[1010]={0},row2[1010]={0};int n,m;int main(){ cin>>n>>m; for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { scanf("%d",&maze[i][j]); if(maze[i][j]==0) { if(col[i])can[i][j]++; if(row[j])can[i][j]++; } else { col[i]=1; row[j]=1; } } } for(int i=n-1; i>=0; i--) { for(int j=m-1; j>=0; j--) { if(maze[i][j]==0) { if(col2[i])can[i][j]++; if(row2[j])can[i][j]++; } else { col2[i]=1; row2[j]=1; } } } __int64 ans=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(maze[i][j]==0) { ans+=can[i][j]; } } } cout<<ans<<endl; return 0;}
0 0
- codeforces - 738B - Spotlights (瞎搞)
- codeforces 738B Spotlights
- CodeForces 738B - Spotlights(前缀和)
- Codeforces Round #380 B - Spotlights
- CodeForces 729B Spotlights(思维题+前缀和)
- Codeforces Round-#380-Div. 2-B-Spotlights
- Codeforces 729B Spotlights 简单暴力
- B. Spotlights
- B. Spotlights
- Codeforces B. Cards Sorting 【瞎搞】
- Codeforces #380(Div.2)B.Spotlights【思维+前缀和优化】
- Codeforces Round #380 (Div. 2) B. Spotlights (模拟)
- Codeforces Round #421 (Div. 1):B. Mister B and PR Shifts(瞎搞)
- Codeforces Round #421 Mister B and PR Shifts(暴力瞎搞)
- Technocup 2017 — Elimination Round 2 (and Codeforces Round 380) Editorial B. Spotlights
- Spotlights
- codeforces #261 C题 Pashmak and Buses(瞎搞)
- codeforces #433C Ryouko's Memory Note(瞎搞)
- 第四十四天学习笔记
- 记NOIP2016
- 权值
- Hiho 125 GeoHash一·编码解码
- 为什么static成员必须在类外初始化,而不能在类的头文件中初始化
- codeforces - 738B - Spotlights (瞎搞)
- 自定义流式布局
- Android WebView中JS和Java沟通机制
- uploadify取消文件上传
- GitHub无法上传jar包解决办法
- C#集合的总结
- 学习技术。
- 463. Island Perimeter
- hdu1257——最少拦截系统(贪心)