| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
操蛋的系统,说了保证3*3的矩阵的,结果给了小于这个规模的,害哥贡献了上十次啊。。。!#include<iostream>
#include<stdio.h>
using namespace std;
#define INF 1e9
#define N 105
struct info
{
int left,right;
int up,down;
bool tag;
}in[30];
int main()
{
while(1)
{
int n,m,i,j,k;
cin>>n>>m;
if(n==0&&m==0)break;
if(n<3||m<3)continue;
char a[N][N];
for(i=0;i<30;i++)
{
in[i].left=in[i].up=INF;
in[i].right=in[i].down=-1;
in[i].tag=false;
}
for(i=0;i<n;i++)
for(j=0;j<m;j++)
{
cin>>a[i][j];
if(a[i][j]!='.')
{
int t=int(a[i][j]-'A');
in[t].left=j<in[t].left?j:in[t].left;
in[t].right=j>in[t].right?j:in[t].right;
in[t].up=i<in[t].up?i:in[t].up;
in[t].down=i>in[t].down?i:in[t].down;
in[t].tag=true;
}
}
for(i=0;i<28;i++)
if(in[i].tag==true)
{
int t1=in[i].up;
int t2=in[i].down;
int t3=in[i].left;
int t4=in[i].right;
if(t2-t1<2||t4-t3<2)continue;
for(j=t1+1;j<t2;j++)//检测内部
{
for(k=t3+1;k<t4;k++)
if(a[j][k]!='.') break;
if(k<t4) break;
}
if(j<t2)continue;
for(j=t3;j<t4+1;j++)//检测边界
{
if((a[t1][j]-'A')!=i)break;
if((a[t2][j]-'A')!=i)break;
}
if(j<t4+1)continue;
for(j=t1;j<t2+1;j++)
{
if((a[j][t3]-'A')!=i)break;
if((a[j][t4]-'A')!=i)break;
}
if(j==t2+1) cout<<(char)(i+'A');
}
cout<<endl;
}
return 0;
}
/*
9 26
ZZZ....................FFF
Z.Z.AAAAAAAAAAAAA......F.F
ZZZ.A...........A......FFF
....A.......BBBBBBBBBB....
....A.......B........BCCC.
....AAAAAAAAB........B..C.
EEE....C....BBBBBBBBBB..C.
E.E....CCCCCCCCCCCCCCCCCC.
EEE.......................
7 25
.........................
....DDDDDDDDDDDDDEEE.....
....D...CCC.....DE.E.....
....D...C.C.....DEEE.....
....D...CCC.....D..AAFFF.
....DDDDDDDDDDDDD..A.F.F.
...................AAFFF.
0 0
Sample Output
B
AD
6 6
AAA...
A.A...
AABBB.
..B.B.
..BBB.
......
B
6 6
AAA...
A.A...
AABBBB
..B..B
..B..B
..BBBB
B
6 6
AAA...
A.A...
BBBBBB
B....B
B....B
BBBBBB
B
6 6
AAA...
ABBBBB
AB...B
.B...B
.BBBBB
......
B
6 6
AAA...
ABBBBB
ABCCCB
.BC.CB
.BCCCB
.BBBBB
C
6 6
AAABBB
A.AB.B
AAABBB
CCCDDD
C.CD.D
CCCDDD
ABCD
9 9
AAAAAAAAA
ABBBBBBBA
ABCCCCCBA
ABCDDDCBA
ABCD.DCBA
ABCDDDCBA
ABCCCCCBA
ABBBBBBBA
AAAAAAAAA
D
9 9
AABBCCDDD
A.B.C.D.D
AABBCCDDD
EEEFFGGHH
E.E.F.G.H
EEEFFGGHH
IIIJKKKLL
I.I.K.K.L
IIIJKKKLL
DEIK
*/
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator