poj1231 模拟?简单几何?
来源:互联网 发布:广西公务员网络考试 编辑:程序博客网 时间:2024/05/18 15:50
/** * poj1231 简单几何 * 这题也根本不是什么搜索题 * 先把所有字母的方块的四个边的值求出来 * 然后为了划分各个字母独立的区块,将原有的方块进行扩充 * 比如 * B * B D * D * 就需要将原有的B方框向下扩充到D,将原有的D方框向上扩充到B * 合并的规则就是 * if(left[i] <= right[j] && left[i] > left[j]) left[i] = left[j]; * if(right[i] >= left[j] && right[i] < right[j]) right[i] = right[j]; * if(top[i] <= bottom[j] && top[i] > top[j]) top[i] = top[j]; * if(bottom[i] >= top[j] && bottom[i] < bottom[j]) bottom[i] = bottom[j]; * 由于扩充都是对称的,所以如果两个方块不能分割,就会相等,所以最后检查是否有相同的方块就行了 */#include <cstdio>using namespace std;const int MAX_NUM = 27;int left[MAX_NUM],right[MAX_NUM],top[MAX_NUM],bottom[MAX_NUM];int main(){ int t,k,p; int x,y; scanf("%d",&t); while(t--){ scanf("%d%d",&k,&p); for(int i=0;i<k;++i){ left[i] = 1<<30; top[i] = 1<< 30; right[i] = 0; bottom[i] = 0; } for(int i=0;i<k;++i){ for(int j=0;j<p;++j){ scanf("%d%d",&x,&y); left[i] = (x < left[i]) ? x : left[i]; right[i] = (x > right[i]) ? x : right[i]; top[i] = (y < top[i]) ? y : top[i]; bottom[i] = (y > bottom[i]) ? y : bottom[i]; } } for(int i=0;i<k;++i){ for(int j=0;j<k;++j){ if(j==i) continue; if(left[i] <= right[j] && left[i] > left[j]) left[i] = left[j]; if(right[i] >= left[j] && right[i] < right[j]) right[i] = right[j]; if(top[i] <= bottom[j] && top[i] > top[j]) top[i] = top[j]; if(bottom[i] >= top[j] && bottom[i] < bottom[j]) bottom[i] = bottom[j]; } } bool flag=true; for(int i=0;i<k;++i){ for(int j=0;j<k;++j){ if(j==i) continue; if(left[i] == left[j] && right[i] == right[j] && top[i] == top[j] && bottom[i] == bottom[j]){ flag = false; } } } if(flag){ printf("YES\n"); } else{ printf("NO\n"); } } return 0;}
0 0
- poj1231 模拟?简单几何?
- 【几何模拟】hdu 3286
- uva 11796 几何模拟
- 【WC2016模拟】几何
- POJ1231 max sum sequences DP
- hdu 3644(几何模拟退火
- poj1410 简单计算几何
- POJ 2007 简单几何
- POJ2526+简单几何
- 两道简单“几何”
- 【索引】简单几何
- Uva11178 二维简单几何
- hdu 2857 简单几何
- Transmitters(简单几何)
- zoj3728_Collision(简单计算几何)
- hdu5365 简单几何问题
- uva5984(简单计算几何)
- HDU1077关于简单几何
- 账户、媒体资源、视图简介 GA谷歌分析
- Displaying status line always
- 环境不同,心情也许就不同
- byte[]转换为Drawable
- xampp下遇到的问题
- poj1231 模拟?简单几何?
- Java在线编译
- view的属性
- statement 和PreparedStatement
- poj1270 DFS
- java中怎么判断一个字符串中包含某个字符或字符串
- Item高度固定下动态设置ListView的高度
- 对台湾视频站点的再次渗透尝试
- poj1321 DFS