【ZOJ3944 The 13th Zhejiang Provincial Collegiate Programming ContestI】【简单模拟】People Counting 照片人数统计 人
来源:互联网 发布:淘宝哪家店铺级别最高 编辑:程序博客网 时间:2024/05/16 07:37
In a BG (dinner gathering) for ZJU ICPC team, the coaches wanted to count the number of people present at the BG. They did that by having the waitress take a photo for them. Everyone was in the photo and no one was completely blocked. Each person in the photo has the same posture. After some preprocessing, the photo was converted into aH×W character matrix, with the background represented by ".". Thus a person in this photo is represented by the diagram in the following three lines:
.O./|\(.)
Given the character matrix, the coaches want you to count the number of people in the photo. Note that if someone is partly blocked in the photo, only part of the above diagram will be presented in the character matrix.
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
The first contains two integers H, W (1 ≤ H, W ≤ 100) - as described above, followed by H lines, showing the matrix representation of the photo.
Output
For each test case, there should be a single line, containing an integer indicating the number of people from the photo.
Sample Input
23 3.O./|\(.)3 4OOO(/|\\()))
Sample Output
14
Author: Lu, Yi
Source: The 13th Zhejiang Provincial Collegiate Programming Contest
#include<stdio.h>#include<iostream>#include<string.h>#include<string>#include<ctype.h>#include<math.h>#include<set>#include<map>#include<vector>#include<queue>#include<bitset>#include<algorithm>#include<time.h>using namespace std;void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }#define MS(x,y) memset(x,y,sizeof(x))#define MC(x,y) memcpy(x,y,sizeof(x))#define MP(x,y) make_pair(x,y)#define ls o<<1#define rs o<<1|1typedef long long LL;typedef unsigned long long UL;typedef unsigned int UI;template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }const int N = 105, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;int casenum, casei;char A[3][4] = { ".O.","/|\\","(.)" };char a[N][N];bool check(int y, int x){for (int i = 0; i < 3; ++i){for (int j = 0; j < 3; ++j)if (A[i][j]!='.' && a[y + i][x + j] == A[i][j])return 1;}return 0;}int main(){scanf("%d", &casenum);for (casei = 1; casei <= casenum; ++casei){int n, m;scanf("%d%d", &n, &m);++n; ++m;MS(a, 0);for (int i = 2; i <= n; ++i)scanf("%s", a[i] + 2);int ans = 0;for (int i = 0; i <= n; ++i){for (int j = 0; j <= m; ++j)ans += check(i, j);}printf("%d\n", ans);}return 0;}/*【trick&&吐槽】1,诗诗写这题的时候采取了错误的拓扑思想。把问题想复杂后>_< 白白浪费了机器时间与罚时,差点血崩可见做题前,严谨思维的重要性。2,程序规格化和过程化很重要,可以减少出错。【题意】.O./|\(.)中非'.'的格子是人的一部分。给你一个图,图上所有人都是上图姿势,然而存在相互遮挡。没人被完全遮挡,(不会有人在相同的位置)问你图上最多一共可以看到多少个人。【类型】简单模拟【分析】注意:没人在相同的位置!于是,我可以直接暴力维护每个位置每个人。【时间复杂度&&优化】O(nm)*/
- 【ZOJ3944 The 13th Zhejiang Provincial Collegiate Programming ContestI】【简单模拟】People Counting 照片人数统计 人
- The 13th Zhejiang Provincial Collegiate Programming Contest - I People Counting
- 【ZOJ3938 The 13th Zhejiang Provincial Collegiate Programming ContestC】【简单模拟】Defuse the Bomb 5个阶段正确决策
- The 13th Zhejiang Provincial Collegiate Programming Contest-Defuse the Bomb(模拟)
- The 13th Zhejiang Provincial Collegiate Programming Contest (杂谈)
- The 13th Zhejiang Provincial Collegiate Programming Contest
- The 13th Zhejiang Provincial Collegiate Programming Contest 部分题解
- 【ZOJ3947 The 13th Zhejiang Provincial Collegiate Programming ContestL】【水题】Very Happy Great BG 简单求和
- The 7th Zhejiang Provincial Collegiate Programming Contest
- The 6th Zhejiang Provincial Collegiate Programming Contest
- The 8th Zhejiang Provincial Collegiate Programming Contest / L - Javabeans
- The 8th Zhejiang Provincial Collegiate Programming Contest / M - Median
- The 8th Zhejiang Provincial Collegiate Programming Contest
- The 9th Zhejiang Provincial Collegiate Programming Contest
- The 5th Zhejiang Provincial Collegiate Programming Contest 部分题解
- The 10th Zhejiang Provincial Collegiate Programming Contest Solution
- The 11th Zhejiang Provincial Collegiate Programming Contest---Talented Chef
- The 11th Zhejiang Provincial Collegiate Programming Contest
- 修改输入框placeholder的样式
- redis 性能优化
- 【ZOJ3941 The 13th Zhejiang Provincial Collegiate Programming ContestF】【贪心 暴力】Kpop Music Party n段part
- 解决Android TextView默认的padding问题
- No qualifying bean of type [] found for deperidency :
- 【ZOJ3944 The 13th Zhejiang Provincial Collegiate Programming ContestI】【简单模拟】People Counting 照片人数统计 人
- Rotatedrawable详解
- 【ZOJ3946 The 13th Zhejiang Provincial Collegiate Programming ContestK】【最短路+贪心 or 最小树形图】Highway Proje
- sql 语句中char varchar 以及nvchar 区别是什么?
- 如何为Android缓存数据到本地
- mybatis中$和#区别
- 【ZOJ3947 The 13th Zhejiang Provincial Collegiate Programming ContestL】【水题】Very Happy Great BG 简单求和
- B树
- 机器学习——BP神经网络模型