- 博客(22)
- 资源 (1)
- 收藏
- 关注
原创 牛课网 Neat Tree(单调栈)
题目描述 It’s universally acknowledged that there’re innumerable trees in the campus of HUST.There is a row of trees along the East-9 Road which consists of N trees. Now that we know the height of each tr...
2018-04-29 22:38:16 265
原创 ZOJ - 3780 Paint the Grid Again (拓扑排序)
这题主要把握两点:1. 完整的一行一定是在最后涂的2.顺最小字典序就是逆最大字典序。#include<cstdio>#include<cmath>#include<vector>#include<queue>#include<stack>#include<cstring>#include<algorithm...
2018-04-25 22:56:03 143
原创 ZOJ - 3777 && ZOJ - 2972(dp )
这两个dp感觉非常类似, 都是dfs会超时, 利用上一层和下一层关系, dp做出来zoj 2972#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;const double ep=1e-10;const int IN...
2018-04-24 16:15:13 197
原创 ZOJ - 3609 (逆元、扩展欧几里得板子)
#include<cstdio>using namespace std;typedef long long ll;ll extend_gcd(ll a, ll b, ll &x, ll &y){ if(!a&&!b) return -1; if(b==0){ x=1; y=0; return a; } ll d=extend_gcd(...
2018-04-22 17:20:15 342
原创 ZOJ - 3211 Dream City (贪心+dp)
思路:增长速度快的只有放在后面砍才能获得最大的收益。dp[i][j]表示从前i棵树中选出j棵树, 在前j天砍,砍得顺序就是排序的顺序#include<bits/stdc++.h>using namespace std;const int INF=0x3f3f3f3f;int T;int n, m;int dp[300][300];pair<int,int> p[...
2018-04-20 11:45:13 181
原创 Colorful Rainbows ZOJ - 2967 (栈的应用)
思路:先排序,斜率从小到大, 斜率相同, b从小到大。斜率相同时, b大的肯定遮挡b小的。所以将斜率相同b小的去掉。剩下斜率都不同。当直线数量<=2时候, 肯定不会遮挡, 所以当出现第三条直线时,判断它与第二条直线的交点是否在第一条直线与第二条直线交点的右边,是的话不遮挡, 否则会遮挡。若遮挡一直找到第一个不遮挡的为止。#include<cstdio>#include<c...
2018-04-19 11:05:16 177
原创 Hurdles of 110m ZOJ - 2972 (动态规划)
#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;const double ep=1e-10;const int INF=0x3f3f3f3f;int n, m;struct node { int t1, t...
2018-04-19 09:07:16 1492
原创 UVA - 10652 Board Wrapping (凸包+多边形面积)
#include<cstdio>#include<cmath>#include<iostream>#include<algorithm>using namespace std;const double ep=1e-10;const int maxn=6e3+10;int cnt;struct Point { double x, y...
2018-04-15 21:31:55 116
转载 UVALive - 3263 That Nice Euler Circuit (几何 蓝书)
#include<cstdio>#include<cmath>#include<iostream>#include<algorithm>using namespace std;const double ep=1e-10;const int maxn=3e2+10;struct Point { double x, y; Point(...
2018-04-15 18:14:55 125
转载 UVA - 11178 Morley's Theorem(几何,蓝书)
#include<cstdio>#include<cmath>using namespace std;struct Point { double x, y; Point (double x=0, double y=0):x(x), y(y){}};typedef Point Vector;Vector operator + (Vector A, Vec...
2018-04-14 22:43:47 132
原创 ZOJ Problem Set - 4016(list容器的用法)
传送门#include<cstdio>#include<cstring>#include<algorithm>#include<list>using namespace std;const int maxn=3e5+10;typedef long long ll;list<int> l[maxn];int main(){...
2018-04-08 15:02:39 391
原创 ZOJ 4019 Schrödinger's Knapsack (dp)
传送门思路: dp题还是做的太少, 不够灵活,这道题自己第一反应是背包,但容量太大,不可行。按题意分析,每一类里各自的价值是相同,所以当在一类中挑选的时候,当然是体积小的优先。所以对于两类来说也是大趋势是体积小的优先, 所以我们可以从小到大枚举A,B类的任意两个区间, 只要这两个区间的体积和小于总容量就行。但是A,B类的物品顺序还有影响,我们用dp[i][j]代表枚举A类的1~i区间,B类的1~j...
2018-04-08 14:01:57 520
原创 HDU 6024(dp)
Building ShopsTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1767 Accepted Submission(s): 633Problem DescriptionHDU’s n classrooms are on ...
2018-04-06 22:06:16 232
原创 HDU 5361(Dijkstra+并查集)
In TouchTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2845 Accepted Submission(s): 754Problem DescriptionThere are n soda living in a str...
2018-04-06 15:51:49 313
原创 CodeForces - 635D(线段树 点更新区间查询)
D. Factory Repairstime limit per test4 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputA factory produces thimbles in bulk. Typically, it can produce up to a thimbles ...
2018-04-06 13:16:06 196
原创 CodeForces - 633C(字典树+dfs回溯)
C. Spy Syndrome 2time limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter observing the results of Spy Syndrome, Yash realised the errors of his ways...
2018-04-06 13:03:13 354
原创 POJ 1185 炮兵阵地(状压dp)
炮兵阵地Time Limit: 2000MS Memory Limit: 65536KTotal Submissions: 30877 Accepted: 11922Description司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队...
2018-04-02 22:42:23 98
原创 HDU 3420 Bus Fair(贪心)
Bus FairTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1131 Accepted Submission(s): 595Problem DescriptionYou are now in Foolish Land. Once ...
2018-04-02 16:53:40 141
原创 628D - Magic Numbers(数位dp)
D. Magic Numberstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputConsider the decimal presentation of an integer. Let's call a number d-magic if di...
2018-04-02 12:13:38 291
原创 ZOJ Seven Segment Display(数位DP)
Seven Segment DisplayTime Limit: 2 Seconds Memory Limit: 65536 KBA seven segment display, or seven segment indicator, is a form of electronic display device for displaying decimal numerals that i...
2018-04-01 22:29:27 164
原创 方格取数(状压DP)
#include<cstdio>#include<iostream>#include<algorithm>using namespace std;typedef long long ll;const int INF=0x3f3f3f3f;const int maxn=25;int n, num[maxn][maxn], sum[maxn][maxn...
2018-04-01 20:42:57 529
原创 蓝桥 矩阵乘法(区间dp)
算法提高 矩阵乘法 时间限制:3.0s 内存限制:256.0MB 问题描述 有n个矩阵,大小分别为a0*a1, a1*a2, a2*a3, ..., a[n-1]*a[n],现要将它们依次相乘,只能使用结合率,求最少需要多少次运算。 两个大小分别为p*q和q*r的矩阵相乘时的运算次数计为p*q*r。输入格式 输入的第一行包含一个整数n,表示矩阵的个数。 第二行包含n+1个数...
2018-04-01 15:28:21 230
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人