设为首页 加入收藏

TOP

HDOJ 5031 Lines
2015-07-20 17:37:04 来源: 作者: 【 】 浏览:3
Tags:HDOJ 5031 Lines


枚举角度DFS。。。。

Lines

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 479 Accepted Submission(s): 140


Problem Description You play a game with your friend. He draws several lines on the paper with n×m square grids (see the left figure). After that, he writes down the number of lines passing through every integer coordinate in a matrix (see the right figure).

\

The number of lines passing though coordinate (i,j) is written in cell (i,j) in the right figure.(i,j both start from 0).

You are given the matrix written by your friend. You need to figure out the possible minimal number of lines your friend drew on the paper.
Input The first line of the input contains an integer T indicating the number of test cases( 0 < T <= 10).

FZ??http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vciBlYWNoIHRlc3QgY2FzZSwgdGhlIGZpcnN0IGxpbmUgY29udGFpbnMgdHdvIGludGVnZXJzIG4sIG0gKDEgodwgbiwgbSCh3CA1MCkgcmVwcmVzZW50aW5nIHRoZSBzaXplIG9mIHRoZSBncmlkcyBvbiB0aGUgcGFwZXIuIFRoZSBmb2xsb3dpbmcgKG4mIzQzOzEpIKHBIChtJiM0MzsxKSBudW1iZXJzIGlzIHdoYXQgeW91ciBmcmllbmQgd3JpdGVzLiBJdCBpcyBndWFyYW50ZWVkIHRoYXQgdGhlIG51bWJlciBvZiBsaW5lcyB5b3VyIGZyaWVuZCBkcmF3cyBkb2VzIG5vdAogZXhjZWVkIDE0LiBFYWNoIGxpbmUgcGFzc2VzIHRocm91Z2ggaW50ZWdlciBjb29yZGluYXRlcyBhdCBsZWFzdCB0aHJlZSB0aW1lcy4KCiAKPGJyPgoKT3V0cHV0CgpGb3IgZWFjaCB0ZXN0IGNhc2UsIHlvdSBuZWVkIHRvIG91dHB1dCB0aGUgbWluaW1hbCBudW1iZXIgb2YgbGluZXMgeW91ciBmcmllbmQgZHJldyBvbiB0aGUgcGFwZXIgaW4gYSBzaW5nbGUgbGluZS4KCiAKPGJyPgoKU2FtcGxlIElucHV0Cgo8cHJlIGNsYXNzPQ=="brush:java;">1 5 4 0 1 0 0 1 0 1 0 1 0 2 1 1 0 0 0 3 1 0 0 1 1 1 0 1 0 1 0 1 0
Sample Output
4

Source 2014 ACM/ICPC Asia Regional Guangzhou Online


#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
       using namespace std; map
       
         DB; int n,m,ans; int mp[60][60]; inline bool is_in(int x,int y) { if(x>=0&&x
        
         =0&y
         
          =ans) return ; if(remain==0) { ans=min(ans,deep); return ; } bool flag=false; for(int i=0;i
          
           



】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDU-4961 Boring Sum STL模拟 下一篇POJ 1149 PIGS 迈克卖猪问题 网络..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·PostgreSQL 索引 - (2025-12-25 22:20:43)
·MySQL Node.js 连接 (2025-12-25 22:20:41)
·SQL 撤销索引、表以 (2025-12-25 22:20:38)
·Linux系统简介 (2025-12-25 21:55:25)
·Linux安装MySQL过程 (2025-12-25 21:55:22)