poj 3923
来源:互联网 发布:淘宝衣服模特 编辑:程序博客网 时间:2024/05/18 00:17
#include<cstring>#include<queue>#include<iostream>#include<cstdio>#include<algorithm>using namespace std;char Map[150][150];int vis[150][150];struct node{ char ch; int lx,ly; int rx,ry;} point[150];int main(){ int n,m; while(scanf("%d%d",&n,&m),n||m) { int i,j,z; int top=0; getchar(); for(i=1; i<=n; i++){ for(j=1;j<=m;j++) scanf("%c",&Map[i][j]); getchar(); } memset(vis,0,sizeof(vis)); for(i=1; i<=n; i++) for(j=1; j<=m; j++) { if(vis[i][j]==0&&Map[i][j]!='.'){ char tch=Map[i][j]; int tempx=i,tempy=j; int ty=tempy+1,tx=tempx+1; int tty=tempy+1,ttx=tempx+1; int lon[5]; for(z=1; z<=4; z++) lon[z]=0; while(ty>=1&&ty<=m&&Map[tempx][ty]==tch){ vis[tempx][ty]=1; ty++; lon[1]++; } ty--; while(tx>=1&&tx<=n&&Map[tx][tempy]==tch){ vis[tx][tempy]=1; tx++; lon[2]++; } tx--; while(tty>=1&&tty<=m&&Map[tx][tty]==tch){ vis[tx][tty]=1; tty++; lon[3]++; } tty--; while(ttx>=1&&ttx<=n&&Map[ttx][ty]==tch){ vis[ttx][ty]=1; ttx++; lon[4]++; } ttx--; if(lon[2]==lon[4]&&lon[1]==lon[3]&&lon[2]>0&&lon[1]>0){ point[top].lx=tempx; point[top].ly=tempy; point[top].rx=ttx; point[top].ry=tty; point[top].ch=tch; top++; } } vis[i][j]=1; } char ans[150]; int top1=0; int l[150],flag=0; memset(l,0,sizeof(l)); for(i=0;i<top;i++){ if(l[i]==0){ flag=0; for(j=i+1;j<top;j++){ if(point[i].lx<point[j].lx&&point[i].ly<point[j].ly) if(point[i].rx>point[j].rx&&point[i].ry>point[j].ry){ flag=1; } } if(flag==0) ans[top1++]=point[i].ch; } } sort(ans,ans+top1); for(i=0;i<top1;i++) printf("%c",ans[i]); printf("\n"); }}
0 0
- poj 3923
- POJ 3923 Ugly Windows
- poj 3923 模拟
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- Java中的泛型之十诫
- IOS开发编程中的问题小结(二)
- linux 下安装ab
- Android事件分发机制
- API实现自动处理物料搬运单
- poj 3923
- VS2008非托管c++访问webservice服务
- Bigcommerce: 网站移动终端项目总结
- SlidingMenu
- Netty4学习笔记(9)-- Channel状态转换
- Android事件分发机制完全解析,带你从源码的角度彻底理解(下)
- zz: python中if __name__ == '__main__': 的解析
- 路由转换
- C++抽象类