CF1913C Game with Multiset 题解】的更多相关文章

题意:给你n个数字s1~sn,要你把它们组成一棵棵二叉树,对这棵二叉树来说,所有节点来自S,并且父节点si<=子节点sj,并且i<j,问你树最少几棵二叉数.树 思路:贪心.我们往multiset加还能加子节点的节点,二分查找一个个大于等于当前插入节点的节点,然后插入,若找不到则重新建一棵树. 没想到set自带lower_bound(),第一次迭代器遍历TLE就想着手动写二分...然后发现自带二分... 代码: #include<iostream> #include<stdio…
题意:n*m的方格,“0 x”表示x轴在x位置切一刀,“0 y”表示y轴在y位置切一刀,每次操作后输出当前面积最大矩形. 思路:用set分别储存x轴y轴分割的点,用multiset(可重复)储存x轴y轴边,每次输出最大的长和最大的宽的积.题目可能重复切.multiset如果直接erase(13)会把所有的13都删掉,如果只想删一个则erase(multiset.find(13)).第一次知道set自带二分... 这里multiset也可以用map<int, int, greater<int&g…
考试拿到题,一看,这不是权值线段树吗? 思路 使用线段树每个节点维护该区间内元素出现次数. 根据题目,对于加入.删除元素,我们可以单点修改(\(+1\).\(-1\)),对于输出,我们可 随便 遍历找一个出现次数为 \(1\) 的元素即可. 代码 具体解释见注释 #include<bits/stdc++.h> #define re read() using namespace std; const int MAXN=1e6+10; int n,q,A[MAXN]; struct SEGTREE…
Vasiliy's Multiset 题目链接: http://codeforces.com/contest/706/problem/D Description Author has gone out of the stories about Vasiliy, so here is just a formal task description. You are given q queries and a multiset A, initially containing only integer…
C. Little Elephant and Shifts Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/220/C Description The Little Elephant has two permutations a and b of length n, consisting of numbers from 1 to n, inclusive. Let's de…
C. Arthur and Table Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/problem/C Description Arthur has bought a beautiful big table into his new flat. When he came home, Arthur noticed that the new table is unstable. In t…
E. Exposition Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/6/E Description There are several days left before the fiftieth birthday of a famous Berland's writer Berlbury. In this connection the local library d…
题外话:这一年的noip应该是最受大众关心的,以至于在百度上输入noip第三个关键字就是noip2007.主要是由于这篇文章:http://www.zhihu.com/question/21107274/answer/18452037   第一题:统计数字 排序/平衡二叉树 受上面这篇文章的影响,我没有用快排,而是用了STL的multiset的count函数来统计出现次数.但事实证明STL的sort足以应付此题.另外的解法是用Treap实现的名次树,效率不及sort但高于multiset.  …
打了快一星期的qtree终于打完了- - (其实还有两题改不出来弃疗了QAQ) orz神AK一星期前就虐完QTREE 避免忘记还是简单写下题解吧0 0 QTREE1 题意: 给出一颗带边权树 一个操作:修改边权 还有一个询问:求x到y路径上边权最大值 树链剖分模版题- -blabla 代码: #include <cstdio> #include <cstring> ; struct inli{ int next,data,lon; inli(,,): next(a),data(b)…
B. Strip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/487/problem/B Description Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right. Now Alexandra wants to split it into some pieces (p…