BZOJ1693: [Usaco2007 Demo]Asteroids】的更多相关文章

n<=500 *n的格子,给m<=10000个格子有人,一炮可以清掉一行或一列的人(莫名的爽!)求最少几炮干掉所有人. 经典二分图模型!行成点,列成点,一个点就连接一行一列,表示这一行或这一列必选其一! 不喜欢匈牙利!跑网络流! #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> using nam…
http://www.lydsy.com/JudgeOnline/problem.php?id=1693 裸匈牙利.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #include <queue> using namespace std; #d…
1629: [Usaco2007 Demo]Cow Acrobats Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 601  Solved: 305[Submit][Status] Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet pre…
1628: [Usaco2007 Demo]City skyline Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 256  Solved: 210[Submit][Status] Description The best part of the day for Farmer John's cows is when the sun sets. They can see the skyline of the distant city. Bessie w…
[BZOJ1630/2023][Usaco2007 Demo]Ant Counting 题意:T中蚂蚁,一共A只,同种蚂蚁认为是相同的,有一群蚂蚁要出行,个数不少于S,不大于B,求总方案数 题解:DP,先列出朴素的方程,用f[i][j]表示前i种,出行j只的方案数,v[i]代表第i中蚂蚁的个数 f[i][j]=∑f[i-1][j-k] (0≤k≤min(j,v[i])) 也可以表示为 f[i][j]=∑f[i-1][k] (j-min(j,v[i])≤k≤j) 发现时间复杂度为均摊O(A^2),…
bzoj2023[Usaco2005 Nov]Ant Counting 数蚂蚁&&bzoj1630[Usaco2007 Demo]Ant Counting 题意: t个族群,每个族群有ni只蚂蚁,同族群蚂蚁没有区别.问从所有蚂蚁中选出s到b只蚂蚁有多少方案.t≤1000,ni≤100. 题解: dp,f[i][j]表示考虑第i个族群,剩下j只蚂蚁没选择.则f[i][j]=sum(f[i-1][j-k]),k=0..min(j,n[i]).然而O(n^3)会超时,注意到可以计算f[i-1][…
观察单词表可以发现: 对于长度为3的单词,前两个字母相同的单词不超过7个 对于长度为4的单词,前两个字母相同的单词不超过35个 于是首先$O(26*26*nm)$预处理出 s1[x][i][j]表示(i,j)右上角里面字母x的出现次数 s2[x][y][i][j]表示(i,j)右上角里面单词xy的出现次数 枚举一个点,计算长度为1的单词的出现次数 枚举两个点,计算长度为2,3,4的单词的出现次数 总时间复杂度为$O(kn^2m^2)$,k不超过43 #include<cstdio> #incl…
题意:链接 方法:乱搞 解析: 出这道题的人存心报复社会. 首先这个单词表-先上网上找这个单词表- 反正总共2265个单词.然后就考虑怎么做即可了. 刚開始我没看表,找不到怎么做,最快的方法我也仅仅是想到了类n^6的做法. 然后我就卡关辣,这关怎么过! 神犇的方法是:观察表.发现规律: 发现表中的单词最长就是4个字母. 所以我们能够考虑求1,2,3,4长度的单词数. 1的话能够直接记录,扫的时候顺带加上即可. 然后神犇说了一句话: 表中长度为4的单词前两个字母同样的单词个数不超过35个. 长度为…
Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away and join the circus. Their hoofed feet prevent them from tightrope walking and swinging from the trapeze (and their last attempt at firing a cow out of a ca…
Description Bessie was poking around the ant hill one day watching the ants march to and fro while gathering food. She realized that many of the ants were siblings, indistinguishable from one another. She also realized the sometimes only one ant woul…