上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: (1)线段树数组开的太小会WA。(2)强制类型转换的时机不对会溢出,这么幼稚的问题竟然疏忽了。(3)插入新线段的时候修改就深入到线段元会TLE,不妨使用lazy的思想,线段树结点中的h域就是tag。(4)离散化,脑海中竟然浮现的是Riemann-Stieltjes积分和Riemann积分的定义。#include #include #include using namespace std;const int MAXN = 40005;typedef struct { int a; int b; int h;}Building;typedef struct { int l;... 阅读全文
posted @ 2013-06-28 19:52 Sinker 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 比较经典的segment tree的应用,线段树中信息的巧妙设计能够使得整个区间的解可以由合并子区间的解得到,本题很好的体现了这一点。#include #include const int MAXN = 50005;typedef struct { int sum; //[l..r]的所有元素和 int prefix; //[l..r]的最大前缀和 int suffix; //[l..r]的最大后缀和 int max; //[l..r]的最大子段和 int l; int r;}Node;Node seg[MAXN ... 阅读全文
posted @ 2013-06-24 23:29 Sinker 阅读(491) 评论(0) 推荐(0) 编辑
摘要: 要合理地设计线段树节点中记录的信息从而能够方便有效地合并同时保持区间所维护的性质。分的时候是二分区间,查询的时候以二分点来分割查询区间,从而最终使整个查询区间得以被覆盖。再通过合并子区间的性质来得到查询区间的性质。 阅读全文
posted @ 2013-06-24 00:29 Sinker 阅读(137) 评论(0) 推荐(0) 编辑
摘要: #include #include const int MAXN = 200005;typedef struct { int l; int r; int max;}Node;Node seg[MAXN * 4];int Max;int fmax(int x,int y){ return x > y ? x : y;}void build(int num,int l,int r){ seg[num].l = l; seg[num].r = r; seg[num].max = -1; if ( l == r ) return; i... 阅读全文
posted @ 2013-06-22 19:43 Sinker 阅读(148) 评论(0) 推荐(0) 编辑
摘要: #include #include const int MAXN = 100005;typedef struct { int cnt; int l; int r;}Node;Node seg[3 * MAXN];int ans[MAXN];void build(int idx,int l,int r){ seg[idx].l = l; seg[idx].r = r; seg[idx].cnt = 0; if ( l == r ) return; int mid = ( l + r ) >> 1; build(idx > 1; ... 阅读全文
posted @ 2013-06-22 17:21 Sinker 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 深度优先搜索中,如果用一个全局变量来代表搜索树中的结点状态,那么除了规定好的能够完成状态转移的操作之外,不能用其他任何方式改变该全局变量的状态,否则就无法确保搜索是完备的。 阅读全文
posted @ 2013-05-19 19:57 Sinker 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Client:import java.io.*;import java.net.*;public class UDPClient { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); DatagramSocket client = new DatagramSocket(); InetAddress addr = InetAdd... 阅读全文
posted @ 2013-05-11 01:55 Sinker 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>#include <string.h>#include <queue>using namespace std;const int INF = 0x7fffffff;const int NIL = -1;const int MAXN = 1005;const int MAXM = 100005;typedef pair<int,int> tuple;int N,M;int S,T,K;int u[MAXM];int v[MAXM];int w[MAXM];int first0[MAXN];int next0[MA 阅读全文
posted @ 2013-05-04 23:46 Sinker 阅读(173) 评论(0) 推荐(0) 编辑
摘要: import java.math.*;import java.util.*;import java.io.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); BigInteger p,m,ans; int b; while ( cin.hasNext() ) { b = ... 阅读全文
posted @ 2013-05-02 13:07 Sinker 阅读(104) 评论(0) 推荐(0) 编辑
摘要: import java.math.*;import java.util.*;import java.io.*;public class Main { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); BigInteger a,b,c,d; while ( cin.hasNext() ) { a = cin.nextBigInteger(); ... 阅读全文
posted @ 2013-05-02 13:01 Sinker 阅读(117) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 8 下一页