
Data Structures
QQQUQ
>_>
展开
-
Codeforces Round #257 (Div. 2)1A Jzzhu and Children
#include #include using namespace std;struct student { int need, pos;};int main(){ int n, m; student s; while (cin >> n >> m) { queue q; for (int i = 1; i <= n; ++i) { cin >> s.nee原创 2014-07-20 08:38:46 · 368 阅读 · 0 评论 -
BZOJ 1012 最大数maxnumber
Description现在请求你维护一个数列,要求提供以下两种操作: 1、 查询操作。语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值。限制:L不超过当前数列的长度。 2、 插入操作。语法:A n 功能:将n加上t,其中t是最近一次查询操作的答案(如果还未执行过查询操作,则t=0),并将所得结果对一个固定的常数D取模,将所得答案插入到数列的末尾。限制:n是非负整数原创 2014-09-18 22:26:49 · 462 阅读 · 0 评论 -
POJ2481 Cows
/*线段树*/#include #include #include #include using namespace std;const int maxn = 100000 + 5;struct node { int s, e, id; node() {}; bool operator <(const node &a)const { if (a.s == s) retu原创 2014-07-29 10:55:29 · 347 阅读 · 0 评论 -
HDU1166 敌兵布阵
#include #include #include using namespace std;const int maxn = 50000 + 5;struct node { int l, r, sum;};node tree[maxn * 4];int t, cas = 0, n, ans;char s[10];void build(int l, int r, in原创 2014-07-27 15:26:06 · 341 阅读 · 0 评论 -
POJ2828 Buy Tickets
/*线段树 区间维护当前可插入的个数*/#include #include #include using namespace std;const int maxn = 200000 + 5;struct node { int l, r, sum;};struct person { int pos, val;};node tree[maxn << 2];person原创 2014-07-28 11:03:01 · 311 阅读 · 0 评论 -
POJ2182 Lost Cows
#include using namespace std;const int maxn = 8000 + 5;struct node { int l, r, len;};node tree[maxn * 4];int n;int ans[maxn], pre[maxn];void build(int l, int r, int root){ tree[root].l原创 2014-07-26 20:09:37 · 355 阅读 · 0 评论 -
HDU1754 I Hate It
/*线段树 单点更新 + 寻找区间最值*/#include #include #include #include using namespace std;const int maxn = 200000 + 5;struct node { int l, r, Max, score;};node tree[maxn * 4];int n, m, ans;void bu原创 2014-07-27 16:41:35 · 391 阅读 · 0 评论 -
POJ2352 Stars
/*Interval Tree*/#include #include #include using namespace std;struct node { int l, r, val;};int n, x, y;node tree[32005 * 4];int level[32005];void creat(int l, int r, int root){ tre原创 2014-07-26 15:02:20 · 353 阅读 · 0 评论 -
POJ3264 Balanced Lineup
#include #include #include #include using namespace std;struct node { int l, r; int MIN, MAX, num;};const int maxn = 500010;const int INF = 100000000;node tree[maxn << 2];int n, q;int原创 2014-07-26 16:53:05 · 363 阅读 · 0 评论 -
POJ2492 A Bug's Life
/*并查集*/#include #include using namespace std;const int MAXN = 2005;int father[MAXN], Rank[MAXN];int cas = 0, t;int n, m;bool flag;void init(){ for (int i = 0; i < n; ++i) { father[i] =原创 2014-07-25 10:01:33 · 387 阅读 · 0 评论 -
POJ1988 Cube Stacking
/*并查集*/#include #include using namespace std;const int MAXN = 30005;int father[MAXN], Rank[MAXN], up[MAXN];int p;void init(){ for (int i = 0; i < MAXN; ++i) { father[i] = i; Rank[i] =原创 2014-07-24 19:08:18 · 502 阅读 · 0 评论 -
POJ2524 Ubiquitous Religions
/*并查集*/#include using namespace std;const int MAXN = 50005;int father[MAXN];int n, m, cas = 0, sum;void init(){ for (int i = 0; i < n; ++i) { father[i] = i; } return;}int getfather(i原创 2014-07-25 11:12:07 · 335 阅读 · 0 评论 -
POJ2236 Wireless Network
/*并查集*/#include #include #include using namespace std;const int MAXN = 1005;int father[MAXN];int n, d;struct node { double x, y; int flag;};node parent[MAXN];void init(){ for (int i原创 2014-07-25 16:49:25 · 360 阅读 · 0 评论 -
POJ1611 The Suspects
#include using namespace std;const int MAXN = 30005;int n, m;int father[MAXN], RANK[MAXN];void init() { for (int i = 0; i < n; ++i) { father[i] = i; RANK[i] = 1; } return;}int find_r原创 2014-07-24 11:21:29 · 368 阅读 · 0 评论 -
BZOJ 1007 水平可见直线[单调栈]
Description 在xoy直角坐标平面上有n条直线L1,L2,...Ln,若在y值为正无穷大处往下看,能见到Li的某个子线段,则称Li为可见的,否则Li为被覆盖的. 例如,对于直线: L1:y=x; L2:y=-x; L3:y=0 则L1和L2是可见的,L3是被覆盖的. 给出n条直线,表示成y=Ax+B的形式(|A|,|B|Input原创 2014-09-16 22:11:03 · 435 阅读 · 0 评论