07 2015 档案
摘要:和昨天晚上做的 A Bug‘s Life是一样思路的题···开始做的时候还是有些小问题,就在各种问题中进步吧。#include#define Size 100000int N, M;int Rel[Size+1], Pre[Size+1];void Init(){ for( int i...
阅读全文
摘要:思路参考这里(较详细)一开始总是WA调了一晚上原来···Init初始化写在scanf上面了···哎╮(╯▽╰)╭anyway!对并查集的理解更深了一步!#include#includeusing namespace std;#define Size 2000struct node{ i...
阅读全文
摘要:#include#include#include#includeusing namespace std;#define Size 200int Gra[Size+1][Size+1];// 由于是单向边 所以一个矩阵可以表示一个带有反向边的残余网络bool Visited[Size+1];int P...
阅读全文
摘要:思路请点这里如果一开始做这道题我应该不会马上想到用BFS做,我还在纠结如何判断路径最短,好在之前做过类似的不容易看出是BFS解的,做这道题时也就明白了广搜的结果就是最短路径这大概就是 题做多了的缘故罢#include#includeusing namespace std;struct Node{ ...
阅读全文
摘要:能想到用广搜来解这道题也够diao了:广搜到 目标节点 就可以得到答案 steps#include#include#includeusing namespace std;struct node{ int Value, Steps; node( int N, int S )...
阅读全文
摘要:之前做过 区间更新的 所以这个做起来要容易些 算是线段树的水题吧都是基本操作 直接贴代码#include#include#define Size 200000using namespace std;struct node{ int L, R, Score; int Max...
阅读全文
摘要:#include#includeusing namespace std;#define Size 100000struct Node{ int L, R; long long Sum, Inc; int Mid() { ...
阅读全文
摘要:#include#includeusing namespace std;#define Size 10000000int Par[Size+1], Sum[Size+1];int GetPar( int a ){ if( Par[a]!=a ) Par[a] = ...
阅读全文
摘要:#include#include#includeusing namespace std;#define Size 50000struct node{ int L, R, V; node* lchild; node* rchild;}Tree[2*Size];...
阅读全文
摘要:#include#includeusing namespace std;const int INF = 0xffffff0;int MIN = INF;int MAX = -INF;struct Node{ int L, R; int Max, Min; i...
阅读全文
摘要:超有爱讲解 点这里#includeusing namespace std;#define Size 1000int Father[Size];int Find( int n ){ while( n != Father[n] ) n = Father[n]; ...
阅读全文
摘要:递归思路 超时算法#includeusing namespace std;#define Size 101int Triangle[Size][Size];int n;int GetAns( int i, int j ){ if( i==n ) return Tr...
阅读全文
摘要:// 思路请点这里#include#include#includeusing namespace std;int board[9][9]; // 棋盘int RowFlag[9][10]; // RowFlag[i][j]=1 表示 在 第i行 已经放了数字 jint ColFlag[9][1...
阅读全文
摘要:见代码,思路清晰#includeusing namespace std;int main(){ int m, n; vectorV; while( cin>>m>>n ) { if( n>=m ) ...
阅读全文
摘要:思路参考这里#include#include#includeusing namespace std;#define Size 1000int table[Size+1][Size+1];int main(){ string A, B; while( cin>>A>>B )...
阅读全文
摘要:相比 HDOJ 的 fatmouse‘s speed 这道题只需要输出 最长子序列的长度#includeusing namespace std;#define Size 1000int main(){ int N1; int table[Size+1]; i...
阅读全文
摘要:求递增子序列的最大和状态转移方程:table[i] = max(table[i]+value[j]) 前提value[i]>value[j], 构成递增】其中jfrom 0 to i-1 table[i]是前i个中的最优状态, value[j] 是 j 的价值#includeusing namesp...
阅读全文
摘要:#include#include#include#include#include#includeusing namespace std;#define Size 1000struct Node{ int Weight, Speed; int index; b...
阅读全文

浙公网安备 33010602011771号