UVA11520 Fill the Square 枚举

来源:互联网 发布:西数移动硬盘在无网络 编辑:程序博客网 时间:2024/05/24 07:01

废话不多说,直接上代码

/*************************************************************************    > File Name: \LJF\UVa\UVa_11520.cpp    > Author: ljf_cnyali    > Mail: 2724424647@qq.com    > Last modifiedz: 2016-08-27 18:43    > Description: This is a large group of God's program information. ************************************************************************/#include<iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<cstring>#include<ctime>#include<algorithm>#include<queue>#include<set>#include<ctime>using namespace std;#define REP(i, a, b) for(int i = (a), _end_ = (b);i <= _end_; ++i)const int maxn = 20;char map[maxn][maxn];int main() {    int n, m;    scanf("%d", &m);    int t = m;    while(m--) {        scanf("%d", &n);        REP(i, 1, n) {            getchar();            REP(j, 1, n)                scanf("%c", &map[i][j]);        }        REP(i, 1, n)            REP(j, 1, n)                if(map[i][j] == '.')                    REP(c, 'A', 'Z') {                        if(i < n && c == map[i + 1][j])                            continue;                        if(i > 1 && c == map[i - 1][j])                            continue;                        if(j < n && c == map[i][j + 1])                            continue;                        if(j > 1 && c == map[i][j - 1])                            continue;                        map[i][j] = c;                        break;                    }        printf("Case %d:\n", t - m);        REP(i, 1, n) {            REP(j, 1, n)                printf("%c", map[i][j]);            puts("");        };    }    return 0;}
1 0