09 2017 档案
摘要:传送门: https://www.luogu.org/problem/show?pid=2691 题目描述 一个n×n栅格是由n行和n列顶点组成的一个无向图,如图所示。用(i,j)表示处于第i行第j列的顶点。除了边界顶点(即满足i=1,i=n,j=1或j=n的顶点(i,j)),栅格中的所有其他顶点都
阅读全文
摘要:1021 石子归并 区间dp 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 int s[1000000],dp[1000][1000],n,m,tot; 5 using namespace std; 6 int m
阅读全文
摘要:P3047 [USACO12FEB]附近的牛Nearby Cows dfs+前缀和处理 1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #define N 1000010 5 using namespace std; 6
阅读全文
摘要:2072 分配房间 二分 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 #define maxn 1000000 5 #define LL long long 6 7 LL n,m,num[maxn],ans; 8
阅读全文
摘要:1388 砍树 二分 1 #include<cstdio> 2 using namespace std; 3 #define maxx(a,b) (a>b?a:b) 4 #define minn(a,b) (a>b?b:a) 5 #define LL long long 6 LL n,m,h[100
阅读全文
摘要:1288 埃及分数 迭代加深搜索+剪枝 1 #include<cmath> 2 #include<cstdio> 3 #include<cstring> 4 #include<iostream> 5 #include<algorithm> 6 using namespace std; 7 #defi
阅读全文
摘要:2752. [济南集训 2017] 数列运算 dp[i]表示到第i个数的答案 枚举前一个加号在j后面 那么到j一共有2^(j-1)种方案,每种方案在j后面都是一个加号,加号后面全是乘号 dp[i]=Σ(dp[j]+2^(j-1)*(a[j+1]*a[j+2]……*a[i])) 这样复杂度为0(n³)
阅读全文
摘要:zhx's contest 1 #include<algorithm> 2 #include<iostream> 3 #include<cstring> 4 #include<cstdio> 5 #include<cmath> 6 using namespace std; 7 #define LL
阅读全文
摘要:P2015 二叉苹果树 和选课差不多 但是并不是每条边的两边 谁是谁的父亲。。 根据边权确立点权 然后转二叉树 树形dp 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1999 4 int n,m,tot,head[m
阅读全文
摘要:P2014 选课 先将这棵树转化成二叉树 dp[i][j]表示以第i门科目为根节点的子树选j门科目最大的学分 记忆化搜索 k是枚举左儿子选的科目数 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1999 4 int n
阅读全文
摘要:P1352 没有上司的舞会 树形dp dp[i][0]表示第i个人没有来的活跃值 dp[i][1]表示第i个人来了的活跃值 第i个人来时,他的直接下属就不可以来 所以 如果k是他的直接下属的话 dp[i][1]+=dp[k][0] 第i个人不来,他的直接下属可以来也可以不来 所以 如果k是他的直接下
阅读全文
摘要:505. 城市 二分花费,然后跑最短路 spfa超时,堆优化dijkstraAC 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 10000+15 4 #define maxm 10000*5+123 5 #define
阅读全文
摘要:P1306 斐波那契公约数 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define LL long long 4 LL a[2][2],b[2][2],c[2][2],f1,f2; 5 #define mod 100000000 6 7
阅读全文
摘要:P1962 斐波那契数列 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define LL long long 4 LL a[2][2],b[2][2],c[2][2],p; 5 #define mod 1000000007 6 7 void
阅读全文
摘要:1431 快乐排队 金钱+位置是定值 所以sort一遍去重就可以判断了 1 #include<algorithm> 2 #include<cstring> 3 #include<cstdio> 4 #define maxn 205000 5 using namespace std; 6 int nu
阅读全文
摘要:1693 水群 题意是求从1状态到n状态最少需要多少体力 可以以体力建边,跑最短路 每个点向他的质数倍数(质数k<=13)连边,并向这个点-1连边 spfa 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000
阅读全文
摘要:167. [USACO Mar07] 月度花费 二分答案 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000 4 int n,m,minn,maxx; 5 int a[maxn]; 6 7 bool chec
阅读全文
摘要:P2038 无线网络发射器选址 注意边界是否小于0 1 #include<bits/stdc++.h> 2 using namespace std; 3 int d,n,num[1000][1000],ans[1000][1000],tot,cnt,maxx; 4 int main() 5 { 6
阅读全文
摘要:14. [网络流24题] 搭配飞行员 建边的时候要先从源点向主飞行员和从副飞行员向汇点连边 输入的时候只在两人之间连边 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 #define maxn 10000 5 #de
阅读全文
摘要:青蛙的约会 exgcd 1 #include<cstdio> 2 #include<iostream> 3 #define LL long long 4 using namespace std; 5 6 LL x,y,n,m,l; 7 8 LL exgcd(LL a,LL b,LL &x,LL &y
阅读全文
摘要:爱在心中 tarjan缩点 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000 4 int n,m,x,y,z,num,low[maxn],tim,cnt,q[maxn],t,ta,a[maxn]; 5 in
阅读全文
摘要:P2912 [USACO08OCT]牧场散步Pasture Walking lca 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000 4 int n,num,m,x,y,z,head[maxn],q,siz
阅读全文
摘要:1503 愚蠢的宠物 1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 6 #define maxn 1000000+100 7 int father[maxn]; 8 in
阅读全文
摘要:P1432 倒水问题 A一直往B里倒 和 B一直往A里倒 取一个步骤较小的方案 输出涨姿势了 1 #include<bits/stdc++.h> 2 using namespace std; 3 int ca,cb,n,l1,l2; 4 5 int main() 6 { 7 while(scanf(
阅读全文
摘要:P2652 同花顺 求出已有的序列中 最长的同花顺 然后用n减去这个长度 以牌的花色为第一关键字排序,不然会wa 排序之后要判重,因为有花色和大小都一样的牌 然后 枚举每张牌,以这张牌为它以前的区间的右端点,再枚举左端点,就可以了 1 #include<bits/stdc++.h> 2 using
阅读全文
摘要:P1041 传染病控制 dfs枚举去掉的子树,更新当前感染节点 emmmm 这个题,每次去掉最大的子树的做法是错误的 比如 hhh,按照那个贪心的思路肯定是先去掉左边的子树,这样答案会是4 但是先去掉右边的子树的话答案就是3 1 #include<bits/stdc++.h> 2 using nam
阅读全文
摘要:P2668 斗地主 统计单牌和对牌的数量 然后 凑顺子,能凑就凑 还有四带balabala和三带balabala 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n,t,s[15],ans,a,b; 4 5 inline void rea
阅读全文
摘要:P2853 [USACO06DEC]牛的野餐Cow Picnic 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n,m,k,p[10000],can[10000]; 4 int w[1000+15][1000+15]; 5 bool v
阅读全文
摘要:P2194 HXY烧情侣 裸tarjan 1 #include<algorithm> 2 #include<iostream> 3 #include<cstring> 4 #include<cstdio> 5 #include<cmath> 6 #include<queue> 7 using nam
阅读全文
摘要:P3119 [USACO15JAN]草鉴定Grass Cownoisseur tarjan缩点,正反spfa,枚举边,更新最大值 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000 4 #define inf
阅读全文
摘要:走楼梯升级版 Description在你成功地解决了上一道走楼梯后,xxy 不禁有些气恼,于是她又在楼梯上跳来跳去,想要你求出她跳的方案数。..xxy 站在一个 tot 阶楼梯下面,他每次可以往上跳 1—n 步,往下跳 1——m 步(由于地心引力跳得比较远),而且在往下跳的时候只能踩在往上跳时踩过的
阅读全文
摘要:P2966 [USACO09DEC]牛收费路径Cow Toll Paths 把点按点权排序,floyd处理最短路径与最小的 ( 路径与最大点权的和),k作为中间节点,能更新的时候,k是当前最大的点权 1 #include<algorithm> 2 #include<iostream> 3 #incl
阅读全文
摘要:P2207 上学路线route 正反两遍spfa,判断某条边是否是在最短路上,如果是的话就建边,跑最大流 1 #include<cstdio> 2 #include<queue> 3 #include<cstring> 4 #include<algorithm> 5 using namespace
阅读全文
摘要:2342. [SCOI2007]kshort k短路
阅读全文
摘要:P2740 [USACO4.2]草地排水Drainage Ditches 最大流模板 1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 #define maxn 10000 5 #define inf 10000000
阅读全文
摘要:P1318 积水面积 将每层可积水的面积加起来 每层可积水的面积=左边第一个比他大右边的所有空位+右边第一个比他大的左边的所有空位-这一层的所有空位(他指当前高度 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000
阅读全文
摘要:P1317 低洼地 模拟 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000 4 5 int n,h[maxn],tot; 6 bool if_; 7 char ch; 8 inline void read(
阅读全文
摘要:U3357 C2-走楼梯 把下楼看成上楼 f[i]表示两次走到i的方案数 1 #include<cstdio> 2 #define N 10000001 3 #define mod 2333333 4 using namespace std; 5 int f[N],n; 6 int main() 7
阅读全文
摘要:1821: [JSOI2010]Group 部落划分 Group 最小生成树 1 #include<algorithm> 2 #include<iostream> 3 #include<cstring> 4 #include<cstdio> 5 #include<queue> 6 #include<
阅读全文
摘要:1217 借教室 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000 4 #define inf 1<<30 5 6 int n,m,tot,num[maxn],q[maxn]; 7 int sta[maxn
阅读全文
摘要:P2678 跳石头 二分 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000 4 #define inf 1<<30 5 6 int n,m,c,pos[maxn]; 7 8 bool check(int n
阅读全文
摘要:P1316 丢瓶盖 二分答案 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n,m,pg[100001]; 4 5 char ch; 6 inline void read(int &now) 7 { 8 int f=1; ch=getc
阅读全文
摘要:P2683 小岛 spfa, 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define maxn 1000000 4 #define inf 1<<30 5 #define LL long long 6 int n,m,s,num,t,he
阅读全文
摘要:P2431 正妹吃月饼 求l到r之间有多少个二进制1 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #define LL long long 5 using namespace std; 6 LL ans; 7 char
阅读全文
摘要:#6092. 「Codeforces Round #418」恋爱循环 二分 1 #include<algorithm> 2 #include<iostream> 3 #include<cstring> 4 #include<cstdio> 5 #include<queue> 6 #include<c
阅读全文
摘要:#6091. 「Codeforces Round #418」幻想特快 1 #include<algorithm> 2 #include<iostream> 3 #include<cstring> 4 #include<cstdio> 5 #include<queue> 6 using namespa
阅读全文
摘要:https://loj.ac/problem/6090 1 #include<algorithm> 2 #include<iostream> 3 #include<cstring> 4 #include<cstdio> 5 #include<cmath> 6 #include<queue> 7 us
阅读全文
摘要:P2483 [SDOI2010]魔法猪学院 k短路模板 1 #include<queue> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 const int maxn=100
阅读全文
摘要:Remmarguts' Date k短路模板 1 #include<queue> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 const int maxn=1005; 7
阅读全文
摘要:P2338 [USACO14JAN]失败的滑雪Bessie Slows Down 模拟
阅读全文
摘要:1054 电梯 题目描述 Description 一个简单的数学模拟题! 有一座电梯,它的性能如下: 上升一层需要6秒钟,下降一层需要4秒钟,如果要让它停下,它会停5秒钟. 现在告诉你它要按顺序到达然后停靠的N个楼层,求它需要的时间. 电梯开始在0层,楼梯共有100层. 输入(elevator.in
阅读全文
摘要:1051. [Vijos1021] Victoria的舞会1
阅读全文
摘要:1052. [Vijos1022] Victoria的舞会2 并查集吧。。。
阅读全文
摘要:997. [東方S2] 射命丸文 二维前缀和
阅读全文
摘要:P2136 拉近距离 题目背景 我是源点,你是终点。我们之间有负权环。 ——小明 题目描述 在小明和小红的生活中,有N个关键的节点。有M个事件,记为一个三元组(Si,Ti,Wi),表示从节点Si有一个事件可以转移到Ti,事件的效果就是使他们之间的距离减少Wi。 这些节点构成了一个网络,其中节点1和N
阅读全文
摘要:P2422 良好的感觉 题目描述 kkk做了一个人体感觉分析器。每一天,人都有一个感受值Ai,Ai越大,表示人感觉越舒适。在一段时间[i, j]内,人的舒适程度定义为[i, j]中最不舒服的那一天的感受值 * [i, j]中每一天感受值的和。现在给出kkk在连续N天中的感受值,请问,在哪一段时间,k
阅读全文