标签:which soft poj ext eof and sid describe int
题目链接:
HDU:http://acm.hdu.edu.cn/showproblem.php?pid=2487
Description
......................... ....AAAAAAAAAAAAA........ ....A...........A........ ....A...........A........ ....A...........A........ ....AAAAAAAAAAAAA........ ......................... Fig-1 ......................... ....AAAAAAAAAAAAA........ ....A...........A........ ....A.......BBBBBBBBBB... ....A.......B........B... ....AAAAAAAAB........B... ............BBBBBBBBBB... ......................... Fig-2 .......................... ....AAAAAAAAAAAAA......... ....A...........A......... ....A.......BBBBBBBBBB.... ....A.......B........BCCC. ....AAAAAAAAB........B..C. .......C....BBBBBBBBBB..C. .......CCCCCCCCCCCCCCCCCC. .......................... Fig-3
Input
Output
Sample Input
9 26 .......................... ....AAAAAAAAAAAAA......... ....A...........A......... ....A.......BBBBBBBBBB.... ....A.......B........BCCC. ....AAAAAAAAB........B..C. .......C....BBBBBBBBBB..C. .......CCCCCCCCCCCCCCCCCC. .......................... 7 25 ......................... ....DDDDDDDDDDDDD........ ....D...........D........ ....D...........D........ ....D...........D..AAA... ....DDDDDDDDDDDDD..A.A... ...................AAA... 0 0
Sample Output
B AD
Source
PS:注意:
7 25
...BBBBBBBBBBBBBBB.......
...BDDDDDDDDDDDDDB.......
...BDAAAAAAAAAAADB.......
...BDA.........ADB.......
...BDAAAAAAAAAAADB.......
...BDDDDDDDDDDDDDB.......
...BBBBBBBBBBBBBBB.......
6 6
AAABBB
A.AB.B
AAABBB
CCCDDD
C.CD.D
CCCDDD
代码例如以下:
#include<cstdio> #include<cstring> const int maxn = 217; char mp[maxn][maxn]; int vis[maxn]; int n,m; int ok(int a,int b) { int i, j; for(i = b; i <= m; i++) { if(mp[a][i]!=mp[a][b]) break; } i--; for(j = a+1; j <= n; j++) //行 { for(int k = b; k <= i; k++)//列 { if(k==b||k==i)//边缘不同样 { if(mp[j][k]!=mp[a][b]) return 0; } else if(mp[j][k]!=‘.‘)//底边 { for(int l = b; l <= i; l++) { if(mp[j][l]!=mp[a][b]) return 0; } return 1; } } } return 0; } int main() { int i,j; while(~scanf("%d%d",&n,&m)) { if(n==0 && m == 0) break; memset(vis,0,sizeof vis); for(int i = 0; i < n; i++) { scanf("%s",mp[i]); } for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(mp[i][j]!=‘.‘&&vis[mp[i][j]-‘A‘]==0) { vis[mp[i][j]-‘A‘]=1; if(ok(i,j)) vis[mp[i][j]-‘A‘]=2; } } } int flag=1; for(int i = 0; i < 26; i++) { if(vis[i] == 2) { if(flag) printf("%c",i+‘A‘); else printf(" %c",i+‘A‘); } } puts(""); } }
POJ 3923 & HDU 2487 Ugly Windows(模拟)
标签:which soft poj ext eof and sid describe int
原文地址:http://www.cnblogs.com/jzdwajue/p/7000425.html