- 博客(10)
- 收藏
- 关注
原创 hdu5695 拓扑排序 优先队列优化
题目链接hdu5695 !ans会爆int #include <bits/stdc++.h> #define inf 0x3f3f3f3f using namespace std; typedef long long ll; const int maxn=1e5+10; vector<int> s[maxn]; int ind[maxn],vis[maxn]; int n,...
2019-08-17 11:05:25
167
原创 hdu 3342 拓扑排序模板题
#include <bits/stdc++.h> using namespace std; const int maxn=1e3+10; vector<int> s[maxn]; int ind[maxn],vis[maxn]; int n,m; bool toop(){ int ans=0; queue<int>q; for(int i=0;i<n...
2019-08-17 10:25:29
217
原创 poj1270 拓扑排序+dfs
原文链接:https://blog.csdn.net/u013480600/article/details/30315289 1.当前被选的字母必须有效(即mark[i]==true)且当前被选的字母vis=false(即还没被选)。 2.当我们从前到后依次选择一个字母x放进topo数组的时候,我们要保证在topo数组的当前位置cnt的前面那些位置中不会出现y这种字母。其中y<x,即y被要求...
2019-08-17 09:58:20
127
原创 STL 优先队列 priority_queue
优:自动排序(如何实现 不会) ①优先队列的头文件&&声明 首先,你需要 #include<queue> using namespace std; 这两个头文件。 ②其次,一个优先队列声明的基本格式是: priority_queue<结构类型> 队列名; 比如: priority_queue <int> i; priority_queue &l...
2019-08-15 11:18:55
205
原创 容斥原理+dfs hdu1796
原题链接[hdu1796](http://acm.hdu.edu.cn/showproblem.php?pid=1796) 容斥原理 (奇加偶减) 所以题目中的ans= A1的倍数的个数—A1,A2的最小公倍数的倍数的个数+A1,A2,A3的最小公倍数的个数—A1,A2,A3,A4的最小公倍数的个数…(以此类推 当然也要+A2的倍数的个数…+A3的倍数的个数…+A4的倍数的个数…) 方法①:使用...
2019-08-13 14:41:01
136
原创 简单dp 方格取数
题目描述 设有N*N的方格图(N ≤ 10,我们将其中的某些方格中填入正整数,而其他的方格中则放入数字0。如下图所示(见样例): 某人从图的左上角的A 点出发,可以向下行走,也可以向右走,直到到达右下角的B点。在走过的路上,他可以取走方格中的数(取走后的方格中将变为数字0)。 此人从A点到B 点共走两次,试找出2条这样的路径,使得取得的数之和为最大。 输入描述: 输入的第一行为一个整数N(表示N...
2019-08-13 09:29:57
96
原创 简单dp hdu1257
分析:需要拦截的导弹数量=最长上升子序列数 每一个后面比前面大的 拦截装置+1; 体会一下 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int maxn=1e5+10; int a[m...
2019-08-10 16:31:07
90
原创 简单dp hdu1176
题目分析: 跟hdu2084类似hdu2084 时间 可以到达的坐标 1s 5 2s 4 5 6 3s 3 4 5 6 7 4s 2 3 4 5 6 7 8 5s 1 2 3 4 5 6 7 8 9 6s 0 1 2 3 4 5 6 7 8 9 10 状态转移方程 dp[i-1][j]=max( dp[i][j],dp[...
2019-08-10 15:58:36
87
原创 简单dp hdu2084数塔
Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的: 有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少? 已经告诉你了,这是个DP的题目,你能AC吗? Input 输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数...
2019-08-10 14:55:47
89
原创 简单线性dp hdu1087
简单线性dp hdu1087 原题链接http://acm.hdu.edu.cn/showproblem.php?pid=1087 // #include #include #include using namespace std; const int maxn=1e3+10; int a[maxn],dp[maxn]; int main(){ int N; while(~scanf("%d...
2019-08-10 14:32:32
120
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人