Pleasant sheep and big big wolf】的更多相关文章

HDU 3046 Pleasant sheep and big big wolf 题目链接 题意:一个n * m平面上,1是羊.2是狼,问最少要多少围墙才干把狼所有围住,每有到达羊的路径 思路:有羊和狼.要分成两个集合互不可达.显然的最小割.建图源点连狼,容量无穷,羊连汇点,容量无穷.然后相邻格子连边.容量为1 代码: #include <cstdio> #include <cstring> #include <queue> #include <algorithm…
Pleasant sheep and big big wolf Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3316    Accepted Submission(s): 1360 Problem Description In ZJNU, there is a well-known prairie. And it attracts p…
Pleasant sheep and big big wolf Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 304664-bit integer IO format: %I64d      Java class name: Main     In ZJNU, there is a well-known prairie. And it attracts pleas…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3046 In ZJNU, there is a well-known prairie. And it attracts pleasant sheep and his companions to have a holiday. Big big wolf and his families know about this, and quietly hid in the big lawn. As ZJNU A…
pid=3046">点击打开链接 题目:在一个N * M 的矩阵草原上,分布着羊和狼.每一个格子仅仅能存在0或1仅仅动物.如今要用栅栏将全部的狼和羊分开.问怎么放,栅栏数放的最少,求出个数? 解析:将狼群看作一个集合,羊群看作一个集合.然后设置源点和汇点,将两点至存在动物的点的距离赋值为1,构图,因为求得是栅栏数,从存在动物的位置向四周发散点赋值为1,即该方向放置一个栅栏.然后能够发现变成了求最小割,即求出最大流.须要注意的是,因为数据比較大,200 * 200.假设设置源点和汇点相差较大…
http://acm.hdu.edu.cn/showproblem.php?pid=3046 题意: 给出矩阵地图和羊和狼的位置,求至少需要建多少栅栏,使得狼不能到达羊. 思路:狼和羊不能到达,最小割最大流问题. 因为狼和羊都有多只,所以我们加一个超级源点和一个超级汇点,将每只狼与超级源点相连,容量为INF,将每只羊与超级汇点相连,容量为INF.对于地图上的点,每个点都与它上下左右相连,容量设为1. 接下来,我们只需要计算出从超级源点到超级汇点的最大流,因为最小割等于最大流. #include<…
题意: 给出最少栏杆数使狼和羊分离 分析: 将狼与源点连,羊与汇点连,容量都为无穷,将图的各个相邻点连接,容量为1 然后题目就转化成最小去掉多少条边使不连通,即求最小割最大流. // File Name: 3046.cpp // Author: Zlbing // Created Time: 2013/9/10 20:41:04 #include<iostream> #include<string> #include<algorithm> #include<cst…
职务地址:HDU 3046 最小割第一发!事实上也没什么发不发的. ..最小割==最大流.. 入门题,可是第一次入手最小割连入门题都全然没思路... sad..对最小割的本质还是了解的不太清楚.. 这题就是对每两个相邻的格子的边界都要进行加边,然后求最大流就OK了. RE了好长时间,注意遍历加边的时候要从1開始,而不是0開始,由于0是源点的.. .(或许仅仅有我才犯这样的错误吧. . .)建图不多说了..仅仅要了解了最小割,建图还是非常easy想的. 代码例如以下: #include <iost…
给一个n*m的数字阵,1表示羊的位置,2表示狼的位置,0表示没有东西,可以通过.在每个格子的4边都可以建立围栏,有围栏的话狼是不能通过的. 现在求最少建立多少围栏能够保证狼无法接触到羊. 题目的模型很简单,直接建立一个超级源点和超级汇点,狼连接远点流量无穷大,羊连接汇点流量无穷大,每个格子和四周的四个格子建立一条流量为1的边,要把狼羊分离就是求最小割了,最大流等于最小割,圆满解决问题. 召唤代码君: #include <iostream> #include <cstdio> #in…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
-----------------------------最优化问题------------------------------------- ----------------------常规动态规划  SOJ1162 I-Keyboard  SOJ1685 Chopsticks SOJ1679 Gangsters SOJ2096 Maximum Submatrix  SOJ2111 littleken bg SOJ2142 Cow Exhibition  SOJ2505 The County…
=============================以下是最小生成树+并查集====================================== [HDU] How Many Tables 基础并查集★ 小希的迷宫 基础并查集★ &&poj1308 Is It A Tree? 基础并查集★ More is better 基础并查集★ Constructing Roads 基础最小生成树★ 畅通工程 基础并查集★ 还是畅通工程 基础最小生成树★ 畅通工程 基础最小生成树★ 畅通…
Pleasant sheep and big big wolf Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 19 Accepted Submission(s): 14   Problem Description In ZJNU, there is a well-known prairie. And it attracts pleasant…
[图论01]最短路 Start Time : 2018-01-02 12:45:00    End Time : 2018-01-23 12:45:00 Contest Status : Running Current System Time : 2018-01-12 14:39:34 Solved Problem ID Title Ratio(Accepted / Submitted)   1001 最短路 51.85%(70/135)   1002 King 46.67%(35/75)  …
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…
python装饰器的作用是在不改变原有函数的基础上,对函数的功能进行增加或者修改. 装饰器语法是python语言更加优美且避免很多繁琐的事情,flask中配置路由的方式便是装饰器. 首先python中一个函数也是可以当做一个对象进行传递的. def sheep(f): def she(): print("I'm a sheep") return f() return she @sheep def wolf(): print("I'm a wolf") if __na…
之前几乎没写过什么这种几何的计算题.在众多大佬的博客下终于记起来了当时的公式.嘚赶快补计算几何和概率论的坑了... 这题的要求,在对两圆相交的板子略做修改后,很容易实现.这里直接给出代码.重点的部分有:两圆在相离(或外交)时输出第一个圆的面积.内涵(或内切)则需要分类讨论,是羊的圈大.还是狼的圈大.以下是代码: #include<iostream> #include<cmath> #include<stdio.h> using namespace std; int ma…
A. Protect Sheep time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided…
http://codeforces.com/contest/948/problem/A   A. Protect Sheep Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his she…
Bob is a farmer. He has a large pasture with many sheep. Recently, he has lost some of them due to wolf attacks. He thus decided to place some shepherd dogs in such a way that all his sheep are protected. The pasture is a rectangle consisting of R × …
D. Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a…
Chloe and pleasant prizes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a pri…
  After a long night of coding, Charles Pearson Peterson is having trouble sleeping. This is not only because he is still thinking about the problem he is working on but also due to drinking too much java during the wee hours. This happens frequently…
D - Chloe and pleasant prizes 链接 http://codeforces.com/contest/743/problem/D 题面 Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponso…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5115 Dire Wolf Time Limit: 5000/5000 MS (Java/Others)Memory Limit: 512000/512000 K (Java/Others) 问题描述 Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not…
Problem Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbit must hide in one of the holes. A wolf searches the rabbit in anticlockwise order. The first hole he get into is the one signed with 0. Then he will…
[题目链接:HDOJ-2952] Counting Sheep Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2476    Accepted Submission(s): 1621 Problem Description A while ago I had trouble sleeping. I used to lie awake,…
Counting sheep... Description: Consider an array of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present). For example, [true, true, true, false, true, tru…
Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not all, Dire Wolves appear to originate from Draenor. Dire wolves look like normal wolves, but these creatures are of nearly twice the size. These powerf…