2013年12月8日
摘要: 先将博客搬至CSDN。 阅读全文
posted @ 2013-12-08 12:06 straw_berry 阅读(164) 评论(0) 推荐(0) 编辑
摘要: A:http://codeforces.com/problemset/problem/370/A 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 int main() 8 { 9 int chess[10][10];10 memset(chess,0,sizeof(chess));11 for(int i = 1; i 2 #include 3 int main() 4 { 5 int a[110][110]; 6 int cnt[110],x,n; 7 ... 阅读全文
posted @ 2013-12-08 11:58 straw_berry 阅读(220) 评论(0) 推荐(0) 编辑
  2013年12月7日
摘要: http://poj.org/problem?id=1273用Dinic求最大流的模板题,注意会有重边。邻接矩阵建图 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn = 510; 7 const int INF = 0x3f3f3f3f; 8 int flow[maxn][maxn];//残量 9 int m,n;10 int dis[maxn];11 int bfs()//按层数“建”图,就是对每层的点用dis标记它到源点的层数12 {13 queueque;14 ... 阅读全文
posted @ 2013-12-07 14:52 straw_berry 阅读(205) 评论(0) 推荐(0) 编辑
  2013年12月2日
摘要: http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2723题意:给出一些字符串u,v,代表u->v,问有几条边是多余的,也就是说去掉那些边后,u仍能到达v。思路:穷举每条边,试着去掉该边,bfs搜索两个点是否仍然可达。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std; 10 char s1[210],s2[210],.. 阅读全文
posted @ 2013-12-02 15:09 straw_berry 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 题目描述Sylvester Stallion is an old horse who likes nothing better than to wander around in the fields around his stable. Sylvester is a little single minded and will walk in a straight line unless there is a rock in this path. If that\'s the case, he does one of three things: 1) if there is no roc 阅读全文
posted @ 2013-12-02 10:32 straw_berry 阅读(273) 评论(0) 推荐(0) 编辑
  2013年11月30日
摘要: DescriptionDearboy, a goods victualer, now comes to a big problem, and he needs your help. In his sale area there are N shopkeepers (marked from 1 to N) which stocks goods from him.Dearboy has M supply places (marked from 1 to M), each provides K different kinds of goods (marked from 1 to K). Once s 阅读全文
posted @ 2013-11-30 22:00 straw_berry 阅读(831) 评论(0) 推荐(0) 编辑
摘要: http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=50#problem/D最小生成树模板,注意的是这里有k个发电站,它们不再需要连接其他的发电站,所以任何两个发电站之间的权值是0; 1 #include 2 #include 3 const int maxn = 110; 4 const int INF = 0x3f3f3f3f; 5 int map[maxn][maxn],power[maxn]; 6 int n,k; 7 8 void prim() 9 {10 int dis[maxn],vis[maxn];11... 阅读全文
posted @ 2013-11-30 17:29 straw_berry 阅读(239) 评论(0) 推荐(0) 编辑
  2013年11月29日
摘要: DescriptionThe galaxy war between the Empire Draco and the Commonwealth of Zibu broke out 3 years ago. Draco established a line of defense called Grot. Grot is a straight line withNdefense stations. Because of the cooperation of the stations, Zibu’s Marine Glory cannot march any further but stay out 阅读全文
posted @ 2013-11-29 21:48 straw_berry 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 题意:给一些物品item[],这些物品的重量在101至300之间,要将这些物品全部放进若干个bins中,已知bins盛的重量为300,可以将bins装满也可以不装满,问放这些物品最少需要几个bins.思路:当时把最关键的地方忽略了,就是物品的重量在101至300之间,这就说明每个bins至多放2个物品。然后从小到大排序,倒着贪心就可以了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 9 class BinPackingEasy10 {11 private:. 阅读全文
posted @ 2013-11-29 14:23 straw_berry 阅读(239) 评论(0) 推荐(0) 编辑
  2013年11月26日
摘要: http://poj.org/problem?id=1364题意真心看不大懂啊。。。现在假设有一个这样的序列,S={a1,a2,a3,a4...ai...at}其中ai=a*si,其实这句可以忽略不看现在给出一个不等式,使得ai+a(i+1)+a(i+2)+...+a(i+n)ki首先给出两个数分别代表S序列有多少个,有多少个不等式不等式可以这样描述给出四个参数第一个数i可以代表序列的第几项,然后给出n,这样前面两个数就可以描述为ai+a(i+1)+...a(i+n),即从i到n的连续和,再给出一个符号和一个ki当符号为gt代表‘>’,符号为lt代表‘02 2 lt 2a2+a3+a40 阅读全文
posted @ 2013-11-26 20:02 straw_berry 阅读(306) 评论(0) 推荐(0) 编辑