I People Counting
来源:互联网 发布:淘宝上外贸是正品吗 编辑:程序博客网 时间:2024/06/05 09:48
当时没想到,现在感觉思路打开就好了
思路:每次遇到一个部分就把身体其他部分一起变为一个不可能的符号并cnt++. 根据这个把相片从头到尾全部扫一遍就好。
#include<iostream>#include<cstring>using namespace std;int H,W,cnt;char photo[105][105];const char m[3][4]={{"-O-"},{"/|\\"},{"(-)"}}; //记录完整人的样子;void change(int i,int j);void print();void count(int i,int j){if(photo[i][j]=='.') return ;else if(photo[i][j]=='O') change(i,j-1),cnt++;else if(photo[i][j]=='/') change(i-1,j),cnt++;else if(photo[i][j]=='|') change(i-1,j-1),cnt++;else if(photo[i][j]=='\\') change(i-1,j-2),cnt++;else if(photo[i][j]=='(') change(i-2,j),cnt++;else if(photo[i][j]==')') change(i-2,j-2),cnt++;//print();}void change(int i,int j){for(int a=0;a<3;a++)for(int b=0;b<3;b++)if(i+a>=0&&i+a<H&&j+b>=0&&j+b<W&&m[a][b]==photo[i+a][j+b]) //一样就变为'.'photo[i+a][j+b]='.';}int main(){int k;cin>>k;while(k--){cin>>H>>W;memset(photo,0,sizeof(photo));for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>photo[i][j];cnt=0;for(int i=0;i<H;i++) //从头到尾遍历一遍;for(int j=0;j<W;j++)count(i,j);cout<<cnt;if(k) cout<<endl;}return 0;} void print(){for(int i=0;i<H;i++){for(int j=0;j<W;j++)cout<<photo[i][j];cout<<endl;}cout<<endl;}
0 0
- I People Counting
- 浙江16年省赛 I题 People Counting
- People Counting
- 13届浙江省省赛 I题 People Counting
- ZOJ 3944People Counting
- zoj 3944 People Counting
- zoj-3944-People Counting
- ZOJ-3944 People Counting
- ZOJ3944-People Counting
- The 13th Zhejiang Provincial Collegiate Programming Contest - I People Counting
- Zoj-5704题 People Counting (带注释) The 13th ZhejiangProvincial Collegiate Programming Contest – I
- People Counting - 16年浙江省省赛I题 ZOJ 3944
- zoj 3944 暴力 People Counting
- acm/icpc 浙江省赛 People Counting
- ZOJ 3944 People Counting(模拟+暴力)
- ZOJ-3944 People Counting From 第13届浙江省赛
- ZOJ Problem Set - 3944(interesting people counting))
- ZOJ 3944People Counting(思维/技巧/模拟)
- Quick Leaner学Python
- Android6.0以后,如何获取当前运行的app
- Android实现IOS向右滑动退出当前Activity
- java源码分析(1)-Integer
- picasso的使用
- I People Counting
- Centos 6.5 安装Oracle 12C RAC
- Leetcode Reverse String 344
- 服务的启动、停止和与活动的通信
- java.lang.Class.isPrimitive()方法实例
- 电荷泵式开关电源的基本电路
- SQL中的cast和convert的用法和区别
- 党课心得一(杂谈)
- 百度前端学院第一阶段任务五