
ACM_数据结构
DATELOST
I'm curious.
展开
-
POJ-2104 主席树板子
DescriptionYou are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to...原创 2020-01-13 23:27:21 · 226 阅读 · 0 评论 -
POJ-1456 二叉堆
题目小根堆#include<iostream>#include<stdio.h>#include<string.h>#include<vector>#include<algorithm>#define op < //小根堆using namespace std;typedef long long ll;con...原创 2019-08-11 13:05:48 · 128 阅读 · 0 评论 -
POJ-2442 二叉堆
DescriptionGiven m sequences, each contains n non-negative integer. Now we may select one number from each sequence to form a sequence with m integers. It’s clear that we may get n ^ m this kind of s...原创 2019-08-12 13:59:27 · 273 阅读 · 0 评论 -
BZOJ-4198 Huffman树
题目单词出现次数即Huffman树叶子结点权值,求出k叉Huffman树权值相同时优先深度最小(已合并次数最少)的合并#include<iostream>#include<stdio.h>#include<string.h>#include<vector>#include<algorithm>#define op <...原创 2019-08-12 20:08:53 · 135 阅读 · 0 评论 -
POJ-1456 贪心并查集
题目优先卖利润大的,并且在过期前尽量晚地卖出建立关于天数的并查集:维护未被占用的最晚的一天对于每个商品,在d天过期,查询d的根节点r在r天卖出,合并r, r-1#include<iostream>#include<vector>#include<stdio.h>#include<algorithm>#include<strin...原创 2019-08-30 18:53:33 · 121 阅读 · 0 评论 -
POJ-1733 边带权并查集
DescriptionNow and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequenc...原创 2019-09-03 23:52:17 · 275 阅读 · 0 评论 -
POJ-1182 拓展域并查集
Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述:第一种说法是"1 X Y",表示X和Y是同类。第二种说法是"2 X Y",表示X吃Y。此人对N个动物,用上述两种说法,一句接一...原创 2019-09-04 22:47:13 · 185 阅读 · 0 评论 -
Acwing-241. 楼兰图腾 树状数组求逆序数
题目在完成了分配任务之后,西部314来到了楼兰古城的西部。相传很久以前这片土地上(比楼兰古城还早)生活着两个部落,一个部落崇拜尖刀(‘V’),一个部落崇拜铁锹(‘∧’),他们分别用V和∧的形状来代表各自部落的图腾。西部314在楼兰古城的下面发现了一幅巨大的壁画,壁画上被标记出了N个点,经测量发现这N个点的水平位置和竖直位置是两两不同的。西部314认为这幅壁画所包含的信息与这N个点的相对位置...原创 2019-09-05 23:47:41 · 143 阅读 · 0 评论 -
cf-650A unordered_map
A. Watchmentime limit per test 3 secondsmemory limit per test 256 megabytesinputstandard inputoutputstandard outputWatchmen are in a danger and Doctor Manhattan together with his friend Daniel Dr...原创 2019-10-02 16:55:35 · 180 阅读 · 0 评论 -
POJ-3764 01-Trie
DescriptionIn an edge-weighted tree, the xor-length of a path p is defined as the xor sum of the weights of edges on p:http://poj.org/problem?id=3764⊕ is the xor operator.We say a path the xor-lon...原创 2019-08-10 22:46:04 · 110 阅读 · 0 评论 -
HDU-1237 中缀表达式转后缀表达式 后缀表达式求值
中缀表达式转后缀表达式 :扫描中缀表达式:1.数字,直接输出2.左括号,左括号入栈3.右括号,不断取栈顶并输出,直到栈顶为左括号,最后左括号出栈4.运算符,不断取栈顶并输出,直栈顶优先级高于此运算符,最后新运算符入栈后缀表达式求值:扫描后缀表达式:1.数字,入栈2.运算符,取出栈顶两个数,运算,结果入栈3.最后栈里剩下的一个数即为答案#include<iostream&...原创 2019-08-01 23:10:41 · 173 阅读 · 0 评论 -
HDU-4699 对顶栈
Sample Input8I 2I -1I 1Q 3LDRQ 2Sample Output23一个栈存光标前的,一个存光标后的#include<bits/stdc++.h>using namespace std;const int N=1e6+6;stack<int>a,b;char op;int c,p,n;int sum[N],...原创 2019-07-31 22:29:49 · 180 阅读 · 0 评论 -
HDU-1950 最长上升 二维偏序
最长上升#include<bits/stdc++.h>using namespace std;const int N=4e4+4;int bit[N],a[N],b[N],n;//bit[i]存以i结尾的最长上升长度,a,b分别为第1,2维偏序,二维偏序inline int lowbit(int x){return x&-x;}inline int add(int ...原创 2019-07-21 13:14:48 · 216 阅读 · 0 评论 -
HDU-1541 树状数组 求前缀和
Problem DescriptionAstronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that...原创 2019-02-17 20:03:00 · 225 阅读 · 0 评论 -
POJ-2559 单调栈
题目单调栈:及时排除不可能的选项,保持决策集合的有效性和秩序性#include<iostream>#include<iomanip>#include<vector>#include<stack>#define P(i,j) make_pair(i,j)using namespace std;typedef long long ll;...原创 2019-08-02 17:54:30 · 204 阅读 · 0 评论 -
HDU-3966 树链剖分 树状数组 点权
Problem DescriptionOur protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the ...原创 2019-07-21 21:59:51 · 185 阅读 · 0 评论 -
POJ-2763 树链剖分 线段树 边权
题目把边权看作点权不知道为啥N=1e5+5会wa,数组要开大点#include<iostream>#include<string.h>#include<stdio.h>using namespace std;const int N=2e5+5;int fa[N],son[N],dep[N],top[N],siz[N],pos[N],fp[N];...原创 2019-07-22 10:59:30 · 159 阅读 · 0 评论 -
P3178 树链剖分 线段树 子树加
题目输入样例#1:5 51 2 3 4 51 21 42 32 53 31 2 13 52 1 23 3输出样例#1:6913说明对于 100% 的数据, N,M<=100000 ,且所有输入数据的绝对值都不会超过 10^6因为子树的dfs序连续,所以直接区间加pos[u]+siz[u]-1,便可实现子树加;#include<bits/stdc+...原创 2019-07-22 14:08:47 · 167 阅读 · 0 评论 -
ACwing-135 最大子序和 单调队列
题目输入一个长度为n的整数序列,从中找出一段长度不超过m的连续子序列,使得子序列中所有数的和最大。输入格式第一行输入两个整数n,m。第二行输入n个数,代表长度为n的整数序列。同一行数之间用空格隔开。输出格式输出一个整数,代表该序列的最大子序和。数据范围1≤n,m≤300000输入样例:6 41 -3 5 1 -2 3输出样例:7区间和 -> 前缀和相减sum[r...原创 2019-08-03 20:18:19 · 168 阅读 · 0 评论 -
cf 600E/570D DSU on the tree 树上启发式合并
学习学习600E板子#include<bits/stdc++.h>using namespace std;typedef long long ll;const int N=2e5+5;int fa[N],son[N],siz[N];struct Edge{ int to,next; Edge(){} Edge(int to,int next):to(to),nex...原创 2019-07-22 21:56:55 · 132 阅读 · 0 评论 -
POJ-3784 对顶堆
DescriptionFor this problem, you will write a program that reads in a sequence of 32-bit signed integers. After each odd-indexed value is read, output the median (middle value) of the elements receiv...原创 2019-07-10 20:36:50 · 227 阅读 · 0 评论