题意:有你一个草坪,草的初始高度都是100,让你用割草机割,割草机只能横着或竖着割,每次割的高度一定,问你能不能割出给定的草坪出来。

考虑任意一个草被割要么是横着要么竖着,所以任意一个草必然是它所在行或列里面高度最大(或相等)的,因此如果存在一个草在它所在的行和列里都不是最大的则无法割出给定的草坪。

/*
* this code is made by wangzhili
* Problem: 1044
* Verdict: Accepted
* Submission Date: 2014-08-08 20:30:21
* Time: 12MS
* Memory: 1724KB
*/
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int mat[111][111];
int main(){
int t, n, m;
scanf("%d", &t);
for(int CASE = 1;CASE <= t; CASE ++){
scanf("%d%d", &n, &m);
for(int i = 0;i < n;i ++){
for(int j = 0;j < m;j ++) scanf("%d", &mat[i][j]);
}
int flag = 0;
for(int i = 0;i < n;i ++){
for(int j = 0;j < m;j ++){
int cnt = 0;
for(int k = 0;k < m;k ++){
if(mat[i][j] < mat[i][k]){
cnt ++;
break;
}
}
for(int k = 0;k < n;k ++){
if(mat[i][j] < mat[k][j]){
cnt ++;
break;
}
}
if(cnt == 2){
flag = 1;
break;
}
}
if(flag) break;
}
printf("Case #%d: ", CASE);
if(flag) printf("NO\n");
else printf("YES\n");
}
return 0;
}

acdream 1044的更多相关文章

  1. BZOJ 1044 木棍分割 解题报告(二分+DP)

    来到机房刷了一道水(bian’tai)题.题目思想非常简单易懂(我的做法实际上参考了Evensgn 范学长,在此多谢范学长了) 题目摆上: 1044: [HAOI2008]木棍分割 Time Limi ...

  2. 一看便知linux下mysql报错ERROR 1044: Access denied for user: '@localhost' to database 'mysql'

    错误信息:ERROR 1044: Access denied for user: '@localhost' to database 'mysql' linux下解决方案: mysql> use ...

  3. BZOJ 1044: [HAOI2008]木棍分割

    Description 求 \(n\) 根木棍长度为 \(L\) ,分成 \(m\) 份,使最长长度最短,并求出方案数. Sol 二分+DP. 二分很简单啊,然后就是方案数的求法. 状态就是 \(f[ ...

  4. nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1044 > 1024

    HTTP Status 500 - type Exception report message description The server encountered an internal error ...

  5. ACdream 1214---矩阵连乘

    ACdream 1214---矩阵连乘 Problem Description You might have noticed that there is the new fashion among r ...

  6. 解决mysqldump: Got error: 1044: Access denied for user

    转自:http://blog.slogra.com/post-512.html 今天给新加的几个数据库备份,在执行mysqldump的时候,居然报mysqldump: Got error: 1044: ...

  7. acdream.LCM Challenge(数学推导)

     LCM Challenge Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit ...

  8. acdream.Triangles(数学推导)

    Triangles Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Stat ...

  9. acdream.A Very Easy Triangle Counting Game(数学推导)

    A - A Very Easy Triangle Counting Game Time Limit:1000MS     Memory Limit:64000KB     64bit IO Forma ...

随机推荐

  1. 一个很好的php分词类库

    PHPAnalysis源程序下载与演示: PHP分词系统 V2.0 版下载 | PHP分词系统演示 | PHPAnalysis类API文档   原文连接地址:http://www.phpbone.co ...

  2. spring 与 CXF 整合 webservice 出现error “Unable to locate Spring NamespaceHandler for XML schema namespace” 总结

    我试了多个版本的spring 发现 出现error : Unable to locate Spring NamespaceHandler for XML schema namespace 并非都是sp ...

  3. redis、memcache、mongoDB有哪些区别(转载)

    转载: http://leandre.cn/database/64.html Memcached Memcached的优点: Memcached可以利用多核优势,单实例吞吐量极高,可以达到几十万QPS ...

  4. PKUSC 模拟赛 day2 上午总结

    今天上午考得不是很好,主要还是自己太弱QAQ 开场第一题给的图和题意不符,搞了半天才知道原来是走日字形的 然后BFS即可 #include<cstdio> #include<cstr ...

  5. lintcode 中等题:find the missing number 寻找缺失的数

    题目 寻找缺失的数 给出一个包含 0 .. N 中 N 个数的序列,找出0 .. N 中没有出现在序列中的那个数. 样例 N = 4 且序列为 [0, 1, 3] 时,缺失的数为2. 注意 可以改变序 ...

  6. 【Linux高频命令专题(20)】du

    概述 显示每个文件和目录的磁盘使用空间. 命令格式 du [选项][文件] 文件缺省就代表当前目录大小 参数 -a或-all 显示目录中个别文件的大小. -b或-bytes 显示目录或文件大小时,以b ...

  7. Android:改变Activity切换方式

    overridePendingTransition(enterAnim, exitAnim); Intent intent =new Intent(this,item2.class); startAc ...

  8. Ibatis,Spring整合(注解方式注入)

    applicationContext.xml <?xml version="1.0" encoding="UTF-8"?> <beans xm ...

  9. [IE编程] 多页面基于IE内核浏览器的代码示例

    有不少人发信问这个问题,我把答案贴在这里: 建议参考 WTL (Windows Template Library) 的代码示例工程TabBrowser  (在WTL目录/Samples/TabBrow ...

  10. bundle update: env: ruby_executable_hooks: No such file or directory

    please open a bug here: https://github.com/mpapis/executable-hooks/issues as a temporary fix try: rv ...