上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 30 下一页
摘要: 1 //tarjan裸题 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 1e4+5; 8 stack s; 9 vector v[maxn]; 10 int dfn[maxn],low[maxn],ins[maxn]; 11 int ant,cn... 阅读全文
posted @ 2017-08-08 11:00 Posase 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 最短路径问题 3 可利用Bellman-Ford算法或者Dijktra算法求解。 4 */ 5 #include 6 #include 7 #include 8 #include 9 using namespace std; 10 const int maxn = 205; 11 const int inf = 0x3f3f3f3f... 阅读全文
posted @ 2017-08-07 10:41 Posase 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 题意让你求交换次序,实际求逆序对数即可 3 而归并排序时,刚好需要比较mid两边的数,所以只需在归并时累加即可 4 5 例:(归并时一定会排好小组内的顺序) 6 7 对应位置: i m j 8 对应数字: 4 5 6 1 2 3 9 10 4 > 1 -> ans += 3;//因为4为前半最小值,则前半部分所有元素符合要求(ans += m... 阅读全文
posted @ 2017-08-03 23:22 Posase 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 排序 之 归并排序 3 T(n) = O(nlogn) 4 通过分治思想,将数组不断二分 5 最后通过合并两组数据(合并数据时间复杂度为O(n))递归实现排序 6 不论什么情况,时间复杂度都为O(nlogn) 7 但是注意付出了开辟空间(t[maxn])的代价 8 */ 9 #include 10 using namespace std; 11 const i... 阅读全文
posted @ 2017-08-03 22:07 Posase 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 using namespace std; 4 const int maxn = 105; 5 int s[maxn];//s[i]表示每行前i个数的和 6 int d[maxn];//d[i]表示每行取i个数时的最大价值 7 int f[10005];//限制数量为k个,往f中背,记录最大价值 8 int n,m,k; 9 i... 阅读全文
posted @ 2017-08-03 08:09 Posase 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 1 //典型的多重背包 2 #include 3 #include 4 using namespace std; 5 int d[1005]; 6 int n,m; 7 void zb(int r,int v) 8 { 9 for(int i = n; i >= r; --i) 10 if(d[i-r] + v > d[i]) 11 ... 阅读全文
posted @ 2017-08-02 20:34 Posase 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 注意两点 3 1. 不可以使用替换可用节点为不可用节点的方法进行DFS 4 因为角落也可能有油,替换了就出不来。(某学长指导) 5 2. 可用通过开一个数组(例如我的b[][]数组) 6 用了存储到当前位置剩余最大油量 7 这样到话,下次若有更优解,则更新b 8 反之无需继续遍历 9 对于BFS,可用结构体记录坐标和到当前位置到剩余... 阅读全文
posted @ 2017-08-01 22:18 Posase 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 int a[1005]; 7 int min(int x, int y) 8 { 9 return x > t; 15 while (t--) 16 { 17 cin >> n; 18 ... 阅读全文
posted @ 2017-08-01 00:24 Posase 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 1 //AC代码。。。表示很晕 2 #include 3 using namespace std; 4 int a[2005],b[2005]; 5 int main() 6 { 7 int n,m,cnt; 8 cin >> n >> m; 9 int t = n/m; 10 int t2 = n%m; 11 if(n%m == 0)... 阅读全文
posted @ 2017-07-31 23:57 Posase 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 1 //贪心,注意特判即可 2 #include 3 using namespace std; 4 int main() 5 { 6 int a,b,ans = 0; 7 cin >> a >> b; 8 while(a+b > 1 && (a != 1 || b != 1) && (a!=0 && b!=0)) 9 { 10 ... 阅读全文
posted @ 2017-07-31 22:03 Posase 阅读(231) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 30 下一页