自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(141)
  • 收藏
  • 关注

原创 文章标题

n个点的有标号无向图的个数 n 个点的有标号无向图的个数:2C2n2^{C_{n}^{2}} n个点的所有点度都是偶数的有标号无向图的个数 n 个点的所有点度都是偶数的有标号无向图的个数:2C2n−12^{C_{n-1}^{2}} n个点的有标号有根树的个数 n 个点的有标号有根树的个数:nn−1n^{n-1} n个点的有标号无根树的个数 n 个点的有标号无根树的个数:nn−2 Cayley定

2017-10-18 19:22:47 183

原创 例题22

不错的矩阵乘法入门题 构造d*d矩阵A=⎡⎣⎢⎢⎢⎢⎢⎢a1100a2010a3000a400...1............ad000⎤⎦⎥⎥⎥⎥⎥⎥A= \begin{bmatrix}a_1 & a_2 & a_3 & a_4 & ... & a_d\\ 1 & 0 & 0 & 0 & ... & 0\\ 0 & 1 & 0 & 0 & ... & 0\\ & & & ...

2017-08-20 17:37:29 371

原创 [uva820] Internet Bandwidth

题目链接题目大意:最大流模板题解:ISAP#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define INF 0x7fffffffconst int M=405;using namespace std;int kase,n,m,se,ed,t;int head[M],last[M]

2017-01-01 10:39:12 342

原创 [hdu4547] CD操作

题目链接题目大意:给一棵n(n<=100000)个节点的树,有两种移动方式:1.到父节点 2.到子树中任意一个节点 m次询问,求两个节点之间的最小次数题解:需要hash……这里直接用的map。然后就是根据lca大力分类讨论了#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <

2017-01-01 10:19:56 319

原创 文章标题

来几点忠告吧 1.机房键盘可能出毛病,不舒服一定换 2.注意Windows和Linux的一些特点(比如Dfs) 5.厕所环境巨差,带拖鞋等话记得高底 这些是影响比赛的很间接的因素,对了记得带肚子疼的药和卫生纸1.测大数据的时候爆栈怎么办? 改栈空间 工具—–编译选项—-“在连接行……”,写一个空格,再复制上这个 -Wl,–stack=8388608//8m

2016-11-17 14:25:31 142

原创 图论

出现频率:每年必考 主要出现在T2,T3

2016-11-17 09:51:41 307

原创 分治法

分治法的基本思想是将一个规模为n的问题分解为k个规模较小的子问题,这些子问题相互独立且与原问题相同。递归的解这些子问题,然后将各子问题的解合并得到原问题的解。

2016-11-17 09:08:38 582

原创 [codevs1026] 逃跑的拉尔夫

题目链接题解:闷声大暴力啊啊啊啊#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int maxn=55;int r,c,sx,sy,n;char s[maxn][maxn],ans[maxn][maxn];int map[maxn][maxn],vis[maxn][maxn]

2016-11-16 17:52:49 211

原创 搜索

大力出奇迹1.对拍 2.骗分回溯法可以被认为是一个有过剪枝的DFS过程

2016-11-16 16:32:57 172

原创

描述元素(点)间的多对多关系(边权)利用图论模型和经典算法,可以解决很多问题

2016-11-16 15:21:35 171

原创 堆和平衡树

堆 维护一棵完全二叉树 找最值可看成O(1),找其他元素只能一个个遍历平衡树 是一种二叉排序树 二叉排序树是一种比较有用的折衷方案。 数组的搜索比较方便,可以直接用下标,但删除或者插入某些元素就比较麻烦。 链表与之相反,删除和插入元素很快,但查找很慢。 二叉排序树就既有链表的好处,也有数组的好处。 在处理大批量的动态的数据是比较有用。将查找的时间复杂度保证在O(logN)范围内。

2016-11-16 15:14:05 478

原创 并查集

合并,查找,集合用到了树的父结点表示法。在并查集中,每个元素都保存自己的父亲结点的编号,如果自己就是根结点,那么父亲结点就是自己。这样就可以用树形结构把在同一集合的点连接到一起了。优化:路径压缩和启发式合并倒过来,可以把删除变成合并

2016-11-16 15:03:36 205

原创 二叉树

存储:用图的方法或用一维数组存 遍历:前中后序遍历使用dfs实现,按层遍历bfs,深度遍历dfsvoid q(int x)//前序{ if(x==0) return; printf("%d",root); q(t[x].l); q(t[x].r);}无根树转有根树:一般用dfs

2016-11-16 15:00:19 200

原创 栈和队列

栈操作规则:先进后出,先出后进 操作:入栈,出栈,判断栈是否为空,取出栈顶元素,计算栈中元素个数 dfs和栈队列操作规则:先进先出,后进后出 操作:入队,出队,判断队是否为空,取出队首元素,计算队列中元素个数 bfs和队列循环队列,双向队列

2016-11-16 14:49:34 225

原创 STL

string头文件:string>定义:string s;//开二维的话直接用char吧……输入:cin>>s;//空格终止getline(cin,a);//读入1行不要用scanf……运算符:string重载了许多运算符,如:+,+= //a+=b会把b拼接在a后面== //判断相等//判断字典序函数:s.find(str)//在s中寻找str,成功返回位置(i

2016-11-16 11:09:04 206

原创 [51nod1640] 天气晴朗的魔法

题目链接题解:题目描述非常excited。显然,二分可以搞(因为没开long long和没写读优又T又WA了n次),最后用读优卡过去了。不过,只需要先kruskal一次求最小生成树(条件1,最大边权尽量小),记录生成最大边权MX,再以MX为最大边权跑最大生成树就行了(条件2,权值和尽量大),比二分不知道高到那里去了#include <iostream>#include <cstdio>#incl

2016-11-16 09:02:43 350

原创 [noip2012tg] 同余方程

题目链接题解:丧病的模板题#include <iostream>#include <cstdio>#include <algorithm>using namespace std;int a,b,d,x,y;void exgcd(int a,int b,int &d,int &x,int &y){ if (!b) {d=a;x=1;y=0;} else {exgcd(b,a

2016-11-12 16:17:39 225

原创 [Usaco07Jan] Running

题目链接题解:dp#include <cstdio>#include <cstring>#include <cmath>#include <string>#include <iostream>#include <algorithm>using namespace std;const int N=10005, M=505;int f[N][M],n,m,d[N];//第i分钟疲劳为j的

2016-11-12 15:45:42 401

原创 [luogu1284] 三角形牧场

题目链接题解:随机化………………#include <iostream>#include <cstdio>#include <cmath>#include <cstdlib>using namespace std;int n,a[41],ans=-1;void wash()//随机洗木板顺序{ for(int i=1;i<=n;i++) { int t=r

2016-11-12 15:10:00 325

原创 [noip2008tg] 火柴棒等式

题目链接题解:打个表……#include <iostream>#include<cstring>#include<cstdio>using namespace std;int num;int ss[10]={6,2,5,5,4,5,6,3,7,6};int find(int x){ num=0; while(x/10>0) { num+=ss[x

2016-11-12 15:04:25 378

原创 [codevs4906] 删数问题

题目链接题解:经典贪心,不过也可以用dp#include<stdio.h>#include<string.h>void find(){ char N[200]; int s; int i=0,j; scanf("%s",N); scanf("%d",&s); while(s>0) /*循环减s次*/ { i=0;/*每次删除后重头开

2016-11-12 15:01:17 399

原创 [noip2005pj] 校门外的树

题目链接题解:非常奇怪的用并查集维护区间的做法#include <iostream>#include <cstdio>using namespace std;int r[100000],f[100000];int find(int x){ return f[x]==x?x:f[x]=find(f[x]);}void uniom(int u,int p){ int x=fi

2016-11-12 14:20:26 478

原创 [noip2000tg] 乘积最大

题目链接题解:区间dp搞一搞#include <iostream>#include <algorithm>#include <string>using namespace std;string s;int n,m;short figure[50];long long dp[50][50],part[50][50];//dp[n][m]指n位数加m个乘号的最大解,part[a][b]储

2016-11-12 14:15:56 310

原创 [noip2014tg] 飞扬的小鸟

题解:看到题目,二话不说就写了个爆搜,拿了50,后来优化了一下,改成了记忆化,O(nm^2),惨遭卡常数(写得太丑了),只有60 dp等以后在写吧,我太弱了QAQ爆搜#include <iostream>#include <cstdio>using namespace std;#define INF 0x3f3f3f3fconst int M=50;int n,m,k;int ans=

2016-11-11 21:02:19 397

原创 [noip2013tg] 火柴排队

题目链接题解:看到题目,很容易想到,当两序列中最大对最大,次大对次大时,结果最小。结合题目给出的要求,很容易想到,如果把序列A用冒泡排序变成序列B,交换的次数就是答案。用O(n^2)模拟一下,就能拿60了,再结合一下冒泡排序交换次数等于逆序对数这一性质,可以用O(nlogn)求出排名数组的逆序对数这里写代码片

2016-11-11 19:26:38 155

原创 贪心

贪心容易写,也容易错……大体范围:最优化问题(具有最优子结构),和dp有相似的地方 可能结合sort,堆,二分等一.调整性问题 【BZOJ】1629: [Usaco2007 Demo]Cow Acrobats(贪心+排序) 【BZOJ】1634: [Usaco2007 Jan]Protecting the Flowers 护花(贪心)二.暴力扫过去后堆维护【BZOJ】1029

2016-11-11 17:16:47 222

原创 [noip2013tg] 积木大赛

题目链接题解:假设有一个已经处理好的序列,要新加入一个数,如果新加入的数小于序列末尾的数,对序列末尾数的每一次操作都可以附带它,如果大于,则需要新增操作数,初始时序列中为0#include <iostream>#include <cstdio>using namespace std;int n,x,y,ans;int main(){ cin>>n; for(int i=1;

2016-11-11 17:05:41 304

原创 模拟

题目说什么,你就做什么出现频率:每年必考 主要出现在Day1 T1&&Day2 T1&&T2,T3题的部分分需要注意的地方: 1.细节方面十分重要,出题人可能会埋一些坑给你,所以在码之前一定要先有大概的思路框架,想好边界等 2.在码前想好大体的框架,清晰的代码流程,以减少调试的时间 3.不要过分考虑程序的时间,追求简介与易写 4.注意边界,码完后不要急着编译,先静态查错,最后觉得

2016-11-11 16:52:15 267

原创 [模板] Other

文件操作freopen("xx.in","r",stdin);freopen("xx.out","w",stdout);读入、输出优化int read(){ char c=getchar();int x=0,f=1; while(c>'9'||c'0') { if(c=='-') f=-1; c=getchar(); }

2016-11-11 15:54:10 192

原创 [Usaco14Mar] Sabotage

题目链接题解:看到题目,马上YY了一个贪心:序列每个数减去初始序列的平均值然后求最大连续字段和。但是!这样的盲目贪心是错误的对于这样一组数据:6 20 30 40 60 89 1来说,如果按照上述贪心法则,结果得到 20 30 1,正解应为20 1二分答案!#include <cstdio>#include <cstring>#include <iostream>using namespace

2016-11-10 21:27:47 423

原创 [模板] 图

最小生成树kruskalvoid kruskal(){ for(int i=1;i<=n;i++) f[i]=i; for(int i=1;i<=m;i++) { x=find(e[i].u),y=find(e[i].v); if(x!=y){ f[x]=y;tot++; ans+=e[i].v

2016-11-10 20:07:42 197

原创 [noip2007tg] 统计数字

题目链接题解:排序……#include <iostream>#include <algorithm>#include <cstdio>using namespace std;long long a[200005];int main(){ int n; cin>>n; for(int i=1;i<=n;i++) scanf("%lld",&a[i]);

2016-11-10 17:54:50 792

原创 [noip2008tg] 笨小猴

题目链接题解:模拟,模拟#include <iostream>#include <cmath>#include <algorithm>#include <cstring>using namespace std;const int M=1005;string s;int mi=M,mx;int num[233];bool is_prime(int z){ if(z==0||

2016-11-10 17:45:01 319

原创 [noip2010tg] 机器翻译

题目链接题解:闷声摸大拟#include <iostream>#include <cstdio>#include <queue>using namespace std;int n,m,tot,x;queue <int> q;int vis[1005];void init(){ cin>>m>>n; for(int i=1;i<=n;i++) {

2016-11-10 17:22:29 258

原创 [noip2011tg] 铺地毯

题目链接题解:闷声大模拟……#include <iostream>#include <cstdio>using namespace std;int n,x,y;const int M=10005;int a[M],b[M],g[M],k[M];void init(){ cin>>n; for(int i=1;i<=n;i++) scanf("%d%d%d%d",

2016-11-10 16:48:18 225

原创 [noip2013tg] 转圈游戏

题目链接题解:手动模拟一下就行#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#define ll long longusing namespace std;ll n,m,k,x,ans;ll fastpow(ll a,ll p) { ll ans=1;a%=n; for

2016-11-10 15:39:31 199

原创 [noip2014tg] 生活大爆炸版石头剪刀布

题目链接题解:手动打表……#include <iostream>#include <cstdio>using namespace std;int x,y;int n,na,nb;int s1,s2;int a[1000],b[1000];void ask(int x,int y){ if(a[x]!=b[y]) { if(a[x]==0)

2016-11-10 14:33:00 244

原创 [noip2014tg] 无线网络发射选址

题目链接题解:四个循环暴力,不需要二维前缀和……#include <iostream>#include <cstdio>using namespace std;int n,m,sum,tot,cnt,x,y,z,d,num;int w[222][233];void init(){ cin>>d>>n; for(int i=1;i<=n;i++) {

2016-11-10 14:15:55 192

原创 [noip2009tg] 潜伏者

题目链接题解:鬼畜模拟#include <iostream>#include <cstring>#include <cstdio>using namespace std;int flag;char s[100],s1[100],p[100];int map[555],vis[555];void init(){ cin>>s>>s1>>p; for(int i=0;i<

2016-11-10 11:25:50 251

原创 [noip2015tg] 神奇的幻方

题目链接题解:闷声大模拟#include <iostream>#include <cstdio>using namespace std;int n,h,l;int map[50][50];void work(){ int x,y; if(h==1&&l!=n){ h=n,l++; return ; } if(l==n&&h!

2016-11-10 10:59:50 208

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除