11520 - Fill the Square
来源:互联网 发布:php常用的系统函数 编辑:程序博客网 时间:2024/05/17 12:53
纯暴力。
#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <cstdlib>using namespace std;const int maxn = 20;const int dx[] = {-1, 0, 1, 0};const int dy[] = {0, 1, 0, -1};int T, n, kase = 0;char str[maxn][maxn];int main() { scanf("%d", &T); while(T--) { scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%s", str[i] + 1); for(int i = 1; i <= n; ++i) { for(int j = 1; j <= n; ++j) { if(str[i][j] == '.') { for(char ch = 'A'; ch != 'Z'; ++ch) { bool ok = true; for(int k = 0; k < 4; ++k) { int nx = dx[k] + i, ny = dy[k] + j; if(ch == str[nx][ny]) ok = false; } if(ok) { str[i][j] = ch; break; } } } } } printf("Case %d:\n", ++kase); for(int i = 1; i <= n; ++i) printf("%s\n", str[i] + 1); } return 0;}
0 0
- 11520 - Fill the Square
- 11520 - Fill the Square
- 11520 - Fill the Square
- UVA 11520 - Fill the Square
- uva 11520 - Fill the Square
- uva 11520 Fill the Square
- Uva-11520-Fill the Square
- uva 11520 - Fill the Square
- UVA 11520 Fill the Square
- UVA 11520Fill the Square
- UVA 11520 Fill the Square
- UVA - 11520 Fill the Square
- Uva 11520 - Fill the Square
- UVA 11520 Fill the Square
- 11520 - Fill the Square (水题)
- UVa 11520 - Fill the Square
- UVA 11520 Fill the Square
- UVa 11520 - Fill the Square
- VB学习要点3----本窗体下Format函数下的操作(包括本窗体下的字体,颜色,大小的更改)
- opc服务器
- 常用Android开发组件之图像类组件
- 实现图片缓存本地 SDWebImage
- hessian矩阵
- 11520 - Fill the Square
- Java的枚举类型用法介绍
- 属性动画详解之ObjectAnimator、ValueAnimator、PropertyValuesHolder、Keyframe 之间关系
- BeanUtils.copyProperties() 用法---转自百度经验
- PHP学习练手(十六)
- 以海温(Surface Sea Temperature)数据为例,介绍如何利用GrADs软件提取.nc文件
- python之禅
- 光纤检测
- java poi操作excel文件 (新建Excel文件 添加行列、单元格)