CodeForces
来源:互联网 发布:淘宝免单哪里找 编辑:程序博客网 时间:2024/06/11 01:43
传送门
题目大意:给定一个图 ,确定能否通过平移整个图 使得两个一样的图拼接成一个矩形,不能旋转。注意是整个图移动,一开始理解错了`````
思路:很简单的一个水题, 看一下这个图本身是不是矩形就可以,如果时矩形就能拼成矩形,否则不能。
查看图是否为矩形的思路: 遍历一遍,找到边界 最上面的行, 最下面行 最左边列 最右边列 在遍历一遍, 只要在这个范围内 出现了 . 那么就不是矩形。
AC 代码:
#include <iostream>#include <cstdio>using namespace std;char mp[550][550];int main(){int n, m;while(~scanf("%d%d", &n, &m)){for(int i=0; i<n; i++)scanf("%s", mp[i]);int ux = 1000, dx = -1;int lx = 1000, rx = -1;for(int i=0; i<n; i++)for(int j=0; j<m; j++)if(mp[i][j] == 'X'){ux = min(ux, i);lx = min(lx, j);dx = max(dx, i);rx = max(rx, j);}int ok = 1;for(int i=0; i<n; i++)for(int j=0; j<m; j++)if(mp[i][j] != 'X' && i >= ux && i<= dx && j >= lx && j <= rx){ok = 0;break;}if(ok) printf("YES\n");else printf("NO\n");}return 0;}
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- django template 基础(二)(在视图中使用模板)
- RedHat6.5系统LVM增加新硬盘实现根文件系统扩容
- 【编程素质】设计模式-单例模式(Singleton pattern)
- 单例模式(饿汉式)---两例
- ACM零起点2017-7-25(二叉搜索树概念)
- CodeForces
- android 6.0权限开发---拍照,打开相册问题2
- 在MFC上调用Halcon窗口显示图像(先列个标题,忙完这阵再补上)
- java中重载与重写的区别
- HDU 5477 A Sweet Journey 贪心 思维
- 未知异常: Maximum call stack size exceeded
- HDU-4547-离线LCA
- 新导入Jar包时遇到NoClassDefFoundError 的解决方法
- [LeetCode] Trapping Rain Water 三种方案 Python