博客
关于我
Problem——B. Tiling Challenge——Codeforces
阅读量:278 次
发布时间:2019-03-01

本文共 1222 字,大约阅读时间需要 4 分钟。

???

?????????????????????????????????????????????????????????????????????????????????????????????????????"NO"?????"YES"?

???

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ll long long#define dd double#define mes(x, y) memset(x, y, sizeof(y))using namespace std;ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b);}struct node { int x, y;};node z[3000];int main() { int n; cin >> n; int k = 0; char a[100][100]; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> a[i][j]; if (a[i][j] == '.') { z[k].x = i; z[k].y = j; ++k; } } } for (int i = 0; i < k; ++i) { int x = z[i].x; int y = z[i].y; if (x < 0 || x >= n || y < 0 || y >= n) { continue; } int cross_x[4] = {-1, 1, 0, 0}; int cross_y[4] = {0, 0, -1, 1}; bool is_cross = false; for (int d = 0; d < 4; ++d) { int nx = x + cross_x[d]; int ny = y + cross_y[d]; if (nx >= 0 && nx < n && ny >= 0 && ny < n) { if (a[nx][ny] == '.') { is_cross = true; break; } } } if (!is_cross) { a[x][y] = '#'; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (a[i][j] == '.') { cout << "NO" << endl; return; } } } cout << "YES" << endl;}

转载地址:http://ugvo.baihongyu.com/

你可能感兴趣的文章
Objective-C ---JSON 解析 和 KVC
查看>>
Objective-C 编码规范
查看>>
Objective-Cfor循环实现Factorial阶乘算法 (附完整源码)
查看>>
Objective-C——判断对象等同性
查看>>
objective-c中的内存管理
查看>>
Objective-C之成魔之路【7-类、对象和方法】
查看>>
Objective-C享元模式(Flyweight)
查看>>
Objective-C以递归的方式实现二叉搜索树算法(附完整源码)
查看>>
Objective-C内存管理教程和原理剖析(三)
查看>>
Objective-C实现 Greedy Best First Search最佳优先搜索算法(附完整源码)
查看>>
Objective-C实现 jugglerSequence杂耍者序列算法 (附完整源码)
查看>>
Objective-C实现 lattice path格子路径算法(附完整源码)
查看>>
Objective-C实现1000 位斐波那契数算法(附完整源码)
查看>>
Objective-C实现2 个数字之间的算术几何平均值算法(附完整源码)
查看>>
Objective-C实现2d 表面渲染 3d 点算法(附完整源码)
查看>>
Objective-C实现2D变换算法(附完整源码)
查看>>
Objective-C实现3n+1猜想(附完整源码)
查看>>
Objective-C实现3n+1猜想(附完整源码)
查看>>
Objective-C实现9x9乘法表算法(附完整源码)
查看>>
Objective-C实现9×9二维数组数独算法(附完整源码)
查看>>