標籤:style blog color os for io
#include <cstdio>#include <iostream>#include <cstring>#include <vector>using namespace std;char map[110][110];int n,m;#define inf 100000struct node{ int x,y;};vector <node> nn;int main(){ while(1) { int i,j,k; scanf("%d%d",&n,&m); if(n==0) break; getchar(); for(i=1;i<=n;i++) { for(j=1;j<=m;j++) scanf("%c",&map[i][j]); getchar(); } for(k=0;k<26;k++) { nn.clear(); int maxx=0,maxy=0,minx=inf,miny=inf; char x=‘A‘+k; int flag=1; for(i=1;i<=n;i++) for(j=1;j<=m;j++) if(map[i][j]==x) { node tmp; tmp.x=i; tmp.y=j; nn.push_back(tmp); } for(i=0;i<nn.size();i++) { if(nn[i].x>maxx) maxx=nn[i].x; if(nn[i].x<minx) minx=nn[i].x; if(nn[i].y>maxy) maxy=nn[i].y; if(nn[i].y<miny) miny=nn[i].y; } if(maxx<minx+2) continue;//printf("aaa"); if(maxy<miny+2) continue; if(nn.size()!=(maxx-minx+maxy-miny)*2) flag=0; for(i=minx+1;i<maxx;i++) for(j=miny+1;j<maxy;j++) if(isupper(map[i][j])) { flag=0; break; } if(flag) printf("%c",x); } printf("\n"); } return 0;}