博客
关于我
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实现猜数字游戏(附完整源码)
查看>>
Objective-C实现猜数字算法(附完整源码)
查看>>
Objective-C实现猴子爬山算法(附完整源码)
查看>>
Objective-C实现生产者和消费者问题(附完整源码)
查看>>
Objective-C实现生产者消费者问题(附完整源码)
查看>>
Objective-C实现生成崩溃dump文件 (附完整源码)
查看>>
Objective-C实现生成数组的所有不同排列算法(附完整源码)
查看>>
Objective-C实现生成正态分布数据(附完整源码)
查看>>
Objective-C实现生成随机高斯分布(附完整源码)
查看>>
Objective-C实现用 PIL 改变对比度算法(附完整源码)
查看>>
Objective-C实现用二维数组实现矩阵的转置(附完整源码)
查看>>
Objective-C实现用半正弦公式计算两个坐标之间的距离算法 (附完整源码)
查看>>
Objective-C实现用蒙特卡洛方法计算圆周率PI算法(附完整源码)
查看>>
Objective-C实现用递归计算给定数的幂算法(附完整源码)
查看>>
Objective-C实现由伪栈表示的队列算法(附完整源码)
查看>>
Objective-C实现由列表表示的队列算法(附完整源码)
查看>>
Objective-C实现电子词典(附完整源码)
查看>>
Objective-C实现电脑锁屏(附完整源码)
查看>>
Objective-C实现相等的每月分期付款算法(附完整源码)
查看>>
Objective-C实现真值表(附完整源码)
查看>>