题意:1 x,表示放进x元素,2表示拿出一个元素,
原创
2023-06-29 00:08:07
6阅读
题意:有 n 天,每天有m个数,开始的前一天没有数据,然后每天从这个里面拿出一个最大的和最小的,求 n 天的最大的和最小的差值相加。 析:一看就知道用set啊,多简单的STL,不过要注意,开long long,和multiset,因为可能数是一样。 代码如下:
转载
2016-07-05 23:47:00
29阅读
直接套STL就过了,水题#include <cstdio
原创
2022-08-17 15:43:06
38阅读
Most crossword puzzle fans are used to anagrams — groups of words with the same letters in di this attribu...
原创
2022-10-18 16:37:10
43阅读
题意不说了。
思路:
先要快速接近目标n 所以 不断取2 4 8 16 32... 直到恰好小于n为止,这时在加1就可以了
STL 中的lower_bound 恰好实现这个功能!
#include
#include
#include
using namespace std;
int a[35
原创
2023-05-15 00:43:37
33阅读
Problem E: Compound Words
You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is
原创
2023-04-21 01:36:19
64阅读
看到大神说location的值不会超过1000,所以这就简单很多了,用一个deg数组记录下来每个点的度,出度-1,入读+1这样。最后判断每个点的度是否为0即可。至于为什么会这样,据说是套数据套出来的,比如在代码里加一句if(a >= 1000) for(;;),get新技能!如果按正常来做的话,我能...
转载
2015-04-24 15:31:00
45阅读
2评论
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=92 给定若干单词,按字典序输出不存在重排的单词。(经测试,不包含重复的单词) 重排单词:每个字母出现次数一样,但顺
转载
2020-05-23 14:47:00
46阅读
2评论
题意:给定两种操作,一种是定义一个数组,另一种是赋值,让你找出哪一步时出错了,出错只有两种,一种是数组越界,另一种是访问未定义变量。 析:当初看到这个题时,感觉好麻烦啊,然后就放过去了,而现在要重新回来做一下,感觉也不好做,做了1个多小时。。。。。 现在分析一下是思路,我觉得我想的比较麻烦,我首先定
转载
2016-06-15 23:34:00
36阅读
10420 - List of ConquestsTime limit: 3.000 secondshttp://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=1361In Act I, Leporello is tellin
原创
2023-04-12 06:11:31
54阅读
题目传送门题意:训练指南P228分析:照着书上的做法,把点插入后把它后面不占优势的点删除,S.size ()就是优势的人数,时间复杂度O (nlogn)#include using namespace std;struct Point { int a, b; Point() {} ...
转载
2016-01-12 11:28:00
81阅读
2评论
分析:栈的应用,遇到右括号便弹出栈顶元素,看是否与右括号相互匹配,其余情况压入栈。 注意:本题有坑,空串空串,为此我跪了数次
转载
2017-08-10 00:27:00
51阅读
2评论
Background背景Stacks and Queues are often considered the bread and butter of data structures and find use in architecture, parsing, operating systems, and discrete event simulation. Stacks are als
原创
2022-08-05 15:40:25
42阅读
Long long ago there is a strong tribe living on the earth. They always have wars and eonqu
原创
2022-08-17 15:46:22
44阅读
题意:作图为n个建筑物的俯视图,右图为从南向北看的正视图,按从左往右的顺序输出可见建筑物的标号。分析:题中已经说了,要么x相同,要么x相差足够大,不会出现精度问题。给这n个建筑物从左往右排序,每个建筑物的两个端点,排序去重以后可以得到m个相邻的小区间。枚举这些区间,判断建筑物是否可见。离散化刚开始接...
转载
2015-01-07 19:24:00
69阅读
2评论
话说STL的I/O流用的还真不多,就着这道题熟练一下。用了两个新函数:cout 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 using namespace std;10 ...
转载
2015-04-24 11:42:00
106阅读
2评论
今天下午略感无聊啊,切点水题打发打发时间,=_=||把所有字符串插入到一个set中去,然后对于每个字符串S,枚举所有可能的拆分组合S = A + B,看看A和B是否都在set中,是的话说明S就是一个复合词。 1 #include 2 #include 3 #include 4 #include...
转载
2015-04-24 15:53:00
83阅读
2评论
#include#includeusing namespace std;const int maxn = 10000;int main(){ int n, q, x, a[maxn], kase = 0; while(cin >> n >> q && n){ cout << "CASE# " << ++kase << ":" << endl;
原创
2022-08-05 15:36:31
21阅读