- 博客(28)
- 收藏
- 关注
原创 bzoj 2054: 疯狂的馒头
并查集加速查找#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn=1000015; int col[maxn],n,m,p,q,f[maxn]; inline int find(int x){return f[x]==x ? x : f[x]=fi
2016-03-31 22:46:43 323
原创 bzoj 3260: 跳
乱搞题… 一定是先走长再走短,两条边。为什么?因为自信; 打表发现C像组合数…然后就乱搞了…#include<bits/stdc++.h> using namespace std; typedef long long ll; const int mod=(1e9)+7; ll qpow(ll a,ll b){ll ans=1,aa=a;for(;b;b>>=1){if(b&1)ans=ans*a
2016-03-31 22:45:23 363
原创 bzoj 3620: 似乎在梦中见过的样子
n^2的kmp暴力可过; 发现竟不会写kmp了…..#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn=15005; const int inf=0x7f7f7f7f; char s[maxn];int p[maxn],k,ans=0,n,g[m
2016-03-31 22:41:14 376
原创 bzoj 3262: 陌上花开
没开权限就想做的一个题,今天终于…2333 排序一维,归并一维,树状数组一维;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn=200005; struct F{ int d1,d2,d3,ans,s;F(){ans=0;s=1;} }
2016-03-31 22:38:04 325
原创 bzoj 3339: Rmq Problem
莫队+对值分块查找;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn=200005; int a[maxn],have[maxn],sum[maxn],n,s,m; struct Q{ int l,r,ans,id; }q[maxn];
2016-03-31 22:33:34 314
原创 bzoj 3319: 黑白树
好神的题…#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn = 1000007; struct E { int to, next, num; E(int to = 0, int next = 0, int num = 0): to
2016-03-31 22:30:42 391
原创 bzoj 2453: 维护队列
基本上同3343;只是要维护每个点左边的与它同色的点;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn=10005; const int maxc=1000005; typedef long long ll; int a[maxn],b[maxn
2016-03-31 22:28:34 413
原创 bzoj 3343: 教主的魔法
分块;对每一块维护一个有序数列,与一个标记,如果修改了不好用了就暴力重建;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn=1000005; typedef long long ll; int a[maxn],b[maxn],add[maxn],
2016-03-31 22:26:17 304
原创 bzoj 3143: [Hnoi2013]游走
先高斯消元求出每个点期望到达次数,再到边; 再利用排序不等式贪心求解;点1一开始就期望1; 要注意点n的特殊性,它原本期望为1,但每个点不能由它转移过去, 它的期望也与其它点无关,就让它为0以方便计算;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=n;i++) using namespace std; const int m
2016-03-31 22:12:26 465
原创 bzoj 2194
FFT;把b数组倒过来就好看了#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<(n);i++) using namespace std; typedef double db; const int maxn = (1 << 20) + 5; const db pi = acos(-1.0); struct virt { db r
2016-03-31 22:03:50 255
原创 bzoj 1037: [ZJOI2008]生日聚会Party
dp乱搞,把男孩想成+1,女孩-1,问题就变成了使任意一段和绝对值不超过k; d(n,m,i,j) 表示n男m女,最大值为i,最小值为j的状态,然后就过了;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; typedef long long ll; const int mo
2016-03-29 23:18:20 355
原创 bzoj 2428: [HAOI2006]均分数据
模拟退火;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=n;i++) using namespace std; double ave=0.0,ans=0.0,tmp=0.0,T=10000.0,minans=1e30; int n,m,sum[30],belong[30],a[30]; void fire(){T=10000.0;
2016-03-29 23:11:33 349
原创 bzoj 1049 [HAOI2006]数字序列
找到的题解#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=n;i++) #define rep2(i,k,n) for(int i=k;i>=n;i--) using namespace std; const int inf = 0x3f3f3f3f; typedef long long ll; const int maxn = 4
2016-03-29 23:07:09 234
原创 51nod 算法马拉松12
题解在这里第K大区间:二分后滑动窗口扫一下;#include<cstdio> #include<algorithm> #include<cstring> using namespace std; const int maxn=100005; typedef long long ll; int a[maxn],n,vis[maxn],b[maxn],top=1,val[maxn],c[maxn],cn
2016-03-28 22:35:31 455
原创 hustoj 2766: 寻找主人
最小表示法;#include<bits/stdc++.h> using namespace std; const int maxn=1000005; char a[maxn],b[maxn]; int n; int mp(char* s){ int i=0,j=1,k=0; while(i<n && j<n && k<n){ int t=s[(i+k)%n]-s[(j
2016-03-28 22:24:59 279
原创 bzoj 3196: Tyvj 1730 二逼平衡树
线段树套平衡树做法;#include<bits/stdc++.h> #define ls x<<1 #define rs x<<1|1 using namespace std; const int N=200005; const int M=3000001; const int inf=0x3f3f3f3f; int root[N],sum[M],s[M],ch[M][2],val[M],key[M
2016-03-28 22:21:57 226
原创 bzoj 3240: [Noi2013]矩阵游戏
题解戳这里#include<bits/stdc++.h> using namespace std; const int maxn=1000005; typedef long long ll; const ll mod=1000000007; ll a,b,c,d,Ans; struct data{ll uni,ord;}n,m; char s[maxn],t[maxn]; void init(cha
2016-03-28 22:15:55 445
原创 bzoj 1923
裸高斯消元;#include<bits/stdc++.h> using namespace std; bitset<1005> a[2005]; char s[1005];int n,m,ans=-1; void gauss(){int tot=0; for(int i=1;i<=n;i++){int j=tot+1; // while(!a[j][i] && j<=m)j
2016-03-28 22:11:55 253
原创 uva 12538
可持续化treap,merge与split时新建结点;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn = 7000155; struct Treap { int ch[maxn][2], s[maxn], val[maxn], key[
2016-03-28 22:09:52 328
原创 bzoj 3224: Tyvj 1728 普通平衡树
模版题; —treap#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn = 400000; const int inf = 0x7f7f7f7f; struct Treap { int ch[maxn][2], s[maxn], sum
2016-03-27 23:27:26 293
原创 bzoj 2957: 楼房重建
维护一个斜率递增的序列;考虑使用线段树 区间维护该区间内的斜率比区间内之前的点都要大的点的数量及最大值 应用线段树的条件是子区间的答案能够合并;显然前面的点影响后面点的答案, 所以在更新的时候要以此分情况。#include<bits/stdc++.h> #define ls x<<1 #define rs x<<1|1 using namespace std; const int maxn=4
2016-03-27 23:23:50 476
原创 bzoj 3505: [Cqoi2014]数三角形
问题转化为求总和减去三点共线的情况数,统计不同的线段累加计算; 两点(a,b),(x,y)的整点数=gcd(x-a,y-b)-1(x>a && y>b);#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=n;i++) using namespace std; typedef unsigned long long ll; ll C[1
2016-03-27 23:09:37 249
原创 bzoj 2844
转题解#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int maxn=100005; typedef unsigned long long ll; const ll mod=10086; ll a[maxn];int n,Q,tot=0;ll bin[60],
2016-03-26 10:36:43 380
原创 hdu 3949 XOR
高斯消元求线性基,再计数求第k小; 个人感觉这样的线性基可以理解成广义的二进制;#include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; const int maxn=10005; ll a[maxn],bin[65],n; int T,m; ll read()
2016-03-25 21:22:04 294
原创 bzoj4443 [Scoi2015]小凸玩矩阵
第k大==第n-k+1小,这样转换就可以二分求最小值了; 因为我们要求的是满足存在一种方法使<=所枚举数的元素个数 大于等于n-k+1的最小值;判定用二分图匹配;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) using namespace std; const int N=251; int a[N][N],n
2016-03-25 18:45:13 337
原创 [Sdoi2013]直径
3124: [Sdoi2013]直径首先是树的直径的一个性质,随便一个点找到的与它距离最长的点一定是直径的一个端点,这样两遍dfs找出直径;在所有直径上的边一定连续,否则不是树,于是我们就可以随便找一条直径,扫一遍上面的点,看其最远距离如果等于直径左端点则左端点右移,右端点则右端点左移然后停止枚举; #include<bits/stdc++.h> #define rep(i,k,n) for(
2016-03-25 17:35:55 461
原创 3631:[JLOI2014]松鼠的新家
3631: [JLOI2014]松鼠的新家树链剖分~~;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<=(n);i++) #define ls 2*x #define rs 2*x+1 using namespace std; const int maxn=300005; struct E{ int to,next;
2016-03-25 17:28:07 430
原创 bzoj 3198 spring
bzoj 3198 spring要求恰好k个jordan筛法公式容斥就可以做了,判断的时候要hash挂链,不然被卡,忘了k=0了,不停wa;#include<bits/stdc++.h> #define rep(i,k,n) for(int i=k;i<(n);i++) using namespace std; const int N=100005; const int mod=231733; co
2016-03-25 17:23:53 345
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人