- 博客(40)
- 资源 (4)
- 收藏
- 关注
原创 hdu 4893 Wow! Such Sequence! 线段树单点更新+区间更新+区间查询
//1312MS 4668K#include #include #include #include using namespace std;typedef long long ll;const int M=90;const int N=100005;ll f[100],sum[N<<2],need[N<<2];bool lazy[N<<2];inline ll Find(
2014-07-30 13:33:02 428
原创 hdu 1532 Drainage Ditches 最大流 水题
//0MS 268K#include #include #include #include #include #include using namespace std;struct edge{ int to, cap, rev; edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev)
2014-07-27 16:39:21 339
转载 POJ 3155 Hard Life 最大密度子图
题目大意:给出一个无向连通图, 找出一个子图,使该子图的边数与点数的比值最大。(最大密度子图)
2014-07-27 11:14:07 396
原创 POJ 3255 Roadblocks 次短路
求次短路,模板题//2788K 235MS#include #include #include #include #include #include using namespace std;typedef pair pii;const int maxn = 5000;const int maxm = 100000;const int inf = 0x7fffffff;ve
2014-07-24 11:30:30 379
原创 POJ 2377 Bad Cowtractors
最大生成树//376K 32MS#include #include #include #include using namespace std;struct edge{ int u, v, cost; edge(int u=0, int v=0, int cost=0) : u(u), v(v), cost(cost){ }};const int max
2014-07-23 17:08:48 344
原创 POJ 3268 Silver Cow Party
给出n个点和m条边,接着是m条边,代表从牛a到牛b需要花费c时间,现在所有牛要到牛x那里去参加聚会,并且所有牛参加聚会后还要回来,给你牛x,除了牛x之外的牛,他们都有一个参加聚会并且回来的最短时间,从这些最短时间里找出一个最大值输出
2014-07-23 11:11:11 376
原创 POJ 1703 Find them, Catch them 二分图 并查集
//636K 313MS#include const int N = 100005;int n, m, f[N];bool rank[N];inline void init(){ for(int i=1; i<=n; ++i){ f[i]=i; rank[i]=0; //初始化所有点都在二分图的一边 }}int find(int
2014-07-21 00:34:17 429
原创 POJ 3614 Sunscreen 贪心 优先队列
这题的模型是给你一些线段和一些点,每个点的使用次数都是有一定限制的,每条线段只能被标记一次,求最多有多少条线段被标记。将奶牛按照阳光强度的最小值从小到大排序。将防晒霜也按照能固定的阳光强度从小到大排序从最小的防晒霜枚举,将所有符合 最小值小于等于该防晒霜的 奶牛的 最大值 放入优先队列之中。然后优先队列是小值先出所以就可以将这些最大值中的最小的取出来。更新答案。
2014-07-19 14:56:55 402
原创 POJ 2386
//160K 16MS#include #include #include #include using namespace std;struct point{ int x, y;};const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};b
2014-07-18 16:52:30 356
原创 CodeForces 2014.7.17 D. Multiplication Table
该函数f(i, j) = i*j沿x方向和y方向都是单调递增的,故考虑用二分求解
2014-07-18 14:41:03 382
原创 POJ 2480 Longge's problem 欧拉函数的应用 积性函数
找时间把题解补上//176K 157MS#include #include #include using namespace std;typedef long long ll;ll F(ll n){ ll m = sqrt(n+0.5); ll ans = n; for(ll i=2; i<=m; ++i) if(n % i == 0){
2014-07-17 16:23:06 392
原创 POJ 3050 Hopscotch DFS
//516K 63MS#include #include #include #include using namespace std;int a[6][6];bool vis[6][6];const int dx[4] = {1, 0, -1, 0};const int dy[4] = {0, 1, 0, -1};set s;int num;inline bool ok
2014-07-17 10:32:43 367
原创 POJ 3187 Backward Digit Sums
暴力搜索//156K 0MS#include #include #include #include using namespace std;int c[12][12];int a[12];void initc(){ memset(c, 0, sizeof(c)); c[0][0] = 1; for(int i=1; i<=10; i++){
2014-07-17 09:39:05 363
转载 POJ 2718 Smallest Difference
DFS嵌套DFS//156K 47MS#include #include #include #include #include //不加此头文件min和abs在一起会出现编译错using namespace std;const int inf = 0x7fffffff;int num[20];bool usea[20], useb[20];int cnt, cnta,
2014-07-16 20:17:02 365
原创 POJ 3669 Meteor Shower BFS
//624K 63MS#include #include #include #include #include using namespace std;struct node{ int x, y, t;};const int INF = 1e9 + 7;const int dx[4] = {1, 0, -1, 0};const int dy[4] = {0, 1,
2014-07-16 16:08:03 458
原创 POJ 3264(2) Balanced Lineup
这次不用区间扩展了。#include #include #include #include using namespace std;#define lson(x) ((x)<<1)#define rson(x) ((x)<<1 | 1)const int MAXN = 50000;const int INF = INT_MAX;int dat1[MAXN<<2], dat2
2014-07-15 17:08:05 321
原创 POJ 2100 Graveyard Design
Time Limit: 10000MS Memory Limit: 64000KTotal Submissions: 4589 Accepted: 980Case Time Limit: 2000MS
2014-07-11 16:54:54 428
原创 POJ 2739 Sum of Consecutive Prime Numbers 素数打表+尺取法
http://poj.org/problem?id=2739普通的查
2014-07-11 11:17:31 397
原创 POJ 3685 Matrix 二维的二分
Time Limit: 6000MS Memory Limit: 65536KTotal Submissions: 4545 Accepted: 1143DescriptionGiven a N × N matrix A, whose element in the i-th row and j-th column Aij is an number that equals i2
2014-07-09 17:52:13 660
原创 POJ 3579 Median 查找中间值 二分
http://poj.org/problem?id=3579这个题求的是一列数所有相互之间差值的序列的最中间的值是多少。看到数据可以看到用普通的n^2方法必定超时。
2014-07-08 00:04:44 4008 1
转载 POJ 1061 青蛙的约会
公青蛙一开始在x位置,母青蛙在y位置。公青蛙每次跳m米,母青蛙每次跳n米,并且都是向右跳的。地球经线长度是L,然后地球是圆的,也就是说,跳到L、L+1、L+2……其实就是跳到0、1、2。 公青蛙想追母青蛙,问多少次后它们能跳到一起。如果它们永远不能相遇,就输出Impossible(好可怜啊!)很明显嘛,就是求一个k,使x + k*m ≡ y + k*n (mod L) 嘛,木有错吧?至少我
2014-07-07 16:13:27 339
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人