zoj 3944 暴力 People Counting
来源:互联网 发布:js 一切皆对象 编辑:程序博客网 时间:2024/05/20 04:14
题意:在一幅照片里统计人的数量;
思路:从上到下,从左到右, 只要不是点,它必定是人身体的一部分, 那么把它周边和该点属于同一个身体的位置变成点,暴力即可
题目链接: http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=3944
#include<set>#include<map>#include<queue>#include<vector>#include<cstdio>#include<climits>#include<iostream>#include<algorithm>using namespace std;int n, m, ans;char s[105][105];bool judge(int x, int y){ if(s[x][y] != '.') return true; return false;}void change(int x, int y){ if(s[x][y] == 'O') { if(x+1 < m && y-1 >= 0 && s[x+1][y-1] == '/') s[x+1][y-1] = '.'; if(x+1 < m && s[x+1][y] == '|') s[x+1][y] = '.'; if(x+1 < m && y+1 < n && s[x+1][y+1] == '\\') s[x+1][y+1] = '.'; if(x+2 < m && y-1 >= 0 && s[x+2][y-1] == '(') s[x+2][y-1] = '.'; if(x+2 < m && y+1 < n && s[x+2][y+1] == ')') s[x+2][y+1] = '.'; } else if(s[x][y] == '/') { if(y+1 < n && s[x][y+1] == '|') s[x][y+1] = '.'; if(y+2 < n && s[x][y+2] == '\\') s[x][y+2] = '.'; if(x+1 < m && s[x+1][y] == '(') s[x+1][y] = '.'; if(x+1 < m && y+2 < n && s[x+1][y+2] == ')') s[x+1][y+2] = '.'; } else if(s[x][y] == '|') { if(y+1 < n && s[x][y+1] == '\\') s[x][y+1] = '.'; if(x+1 < m && y-1 >= 0 && s[x+1][y-1] == '(') s[x+1][y-1] = '.'; if(x+1 < m && y+1 < n && s[x+1][y+1] == ')') s[x+1][y+1] = '.'; } else if(s[x][y] == '\\') { if(x+1 < m && y-2 >= 0 && s[x+1][y-2] == '(') s[x+1][y-2] = '.'; if(x+1 < m && s[x+1][y] == ')') s[x+1][y] = '.'; } else if(s[x][y] == '(') { if(y+2 < n && s[x][y+2] == ')') s[x][y+2] = '.'; } s[x][y] = '.';}int main(){ int t; scanf("%d", &t); while(t--) { ans = 0; scanf("%d%d", &m, &n); for(int i = 0; i < m; i++) scanf("%s", s[i]); for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { if(judge(i, j)) ans++, change(i, j); } } printf("%d\n", ans); } return 0;}
0 0
- zoj 3944 暴力 People Counting
- ZOJ 3944 People Counting(模拟+暴力)
- ZOJ 3944People Counting
- zoj 3944 People Counting
- zoj-3944-People Counting
- ZOJ-3944 People Counting
- ZOJ-3944 People Counting From 第13届浙江省赛
- ZOJ Problem Set - 3944(interesting people counting))
- ZOJ 3944People Counting(思维/技巧/模拟)
- People Counting - 16年浙江省省赛I题 ZOJ 3944
- ZOJ 3944-People Counting【模拟】(2016浙江省大学生程序设计竞赛)
- People Counting
- I People Counting
- ZOJ3944-People Counting
- zoj 2682 People like People
- Zoj-5704题 People Counting (带注释) The 13th ZhejiangProvincial Collegiate Programming Contest – I
- ACM刷题之ZOJ———— People Counting
- zoj 3519 Beautiful People
- 2.oracle的dump理解二 Buffer Header和Block Header
- 通过applicationContext文件配置项目首页,<mvc:view-controller...>
- 排颜色 II
- C++游戏内进程条
- Django基本命令
- zoj 3944 暴力 People Counting
- VS2010 MFC 读取Excel(2)
- GDOI2016模拟1总结
- Leetcode Symmetric Tree 101
- IOS设计模式之外观模式
- Android中的Environment.getExternalStorageState使用
- Button 中 onTouch 和 onClick 关系
- 3.oracle的dump理解三 DUMP块
- The 13th Zhejiang Provincial Collegiate Programming Contest - I People Counting