数据结构
一个刚入行的小菜鸡
这个作者很懒,什么都没留下…
展开
-
C++中的compare比较字符串
在C语言中的字符串比较使用的strcmp函数,但在C++中使用的是compare函数。格式:字符串A.compare(字符串B)(其中还可以指定子串比较,格式:A.compare(0,3,B,4,3)说明字符串A中的从下标为0开始的3个字符和字符串B中的第4个字符串开始的3个字符进行比较)结果返回:当字符串A和字符串B相等时,返回0当字符串A小于字符串B时,返回-1当字符串A大于字符串B时,返回1注意:compare函数是逐个字符进行比较的,当比较出结果后,后面的字符就不会进行比较了。#inc原创 2021-03-31 14:53:00 · 3437 阅读 · 0 评论 -
Gold Balanced Lineup
/*Gold Balanced Lineup Farmer John’s N cows (1 ≤ N ≤ 100,000) share many similarities. In fact, FJ has been able to narrow down the list of features shared by his cows to a list of only K different f转载 2017-04-22 19:56:40 · 335 阅读 · 0 评论 -
Babelfish
/*Babelfish You have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.转载 2017-04-22 19:54:32 · 292 阅读 · 0 评论 -
Colored Sticks
/*Colored Sticks You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the end转载 2017-04-22 19:53:04 · 256 阅读 · 0 评论 -
Mayor's posters
/*Mayor’s posters The citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all places at their whim. The city co转载 2017-04-22 19:51:00 · 238 阅读 · 0 评论 -
Squares
/*Squares A square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating about its centre by 90 degrees gives the same p转载 2017-04-22 19:49:19 · 201 阅读 · 0 评论 -
Fence Repair
/*Fence Repair Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1<=N<= 20,000) planks of wood, each having some integer len转载 2017-04-15 18:08:52 · 204 阅读 · 0 评论 -
Product
/*Product There is an array of N integer numbers in the interval from -30000 to 30000. The task is to select K elements of this array with maximal possible product. Input The input consists of N +原创 2017-04-15 10:46:17 · 217 阅读 · 0 评论 -
Spell checker
/*Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 25450 Accepted: 9308 Description You, as a member of a development team for a new spell checking program, are原创 2017-04-14 19:39:07 · 468 阅读 · 0 评论 -
中缀表达式转后缀表达式
/*郁闷的C小加(一) 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 我们熟悉的表达式如a+b、a+b*(c+d)等都属于中缀表达式。中缀表达式就是(对于双目运算符来说)操作符在两个操作数中间:num1 operand num2。同 理,后缀表达式就是操作符在两个操作数之后:num1 num2 operand。ACM队的“C小加”正在郁闷怎样把一个中缀表达式原创 2017-04-14 17:52:51 · 257 阅读 · 0 评论 -
Ultra-QuickSort
/*Ultra-QuickSort In this problem, you have to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping two adjacent sequence elements until the s转载 2017-04-14 17:36:22 · 689 阅读 · 0 评论 -
Check the difficulty of problems
/*Check the difficulty of problems Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually expect the contest result satisfy the follow转载 2017-04-18 17:14:45 · 289 阅读 · 0 评论 -
ALL in ALL
/*All in All You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we wi原创 2017-04-12 20:13:25 · 250 阅读 · 0 评论 -
最小值
/*最小值 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 输入N个数,M次查询。 每次查询给出一个数x。 要求:每次查询输出前x个数中第i小的数。(i为第i次查询) 你可以假设M <= N,Xi <= Xi+1 <= Xi+2 <= ……. <= Xm (Xm <= N). 输入 Line0:T Line1: N,M Line2…LineN+1转载 2017-04-12 17:32:17 · 331 阅读 · 0 评论 -
小猴子下落
/*小猴子下落 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 有一颗二叉树,最大深度为D,且所有叶子的深度都相同。所有结点从左到右从上到下的编号为1,2,3,·····,2的D次方减1。在结点1处放一个小 猴子,它会往下跑。每个内结点上都有一个开关,初始全部关闭,当每次有小猴子跑到一个开关上时,它的状态都会改变,当到达一个内结点时,如 果开关关闭,小猴子往原创 2017-04-12 17:30:53 · 186 阅读 · 0 评论 -
士兵杀敌(二)
/*士兵杀敌(二) 时间限制:1000 ms | 内存限制:65535 KB 难度:5 描述 南将军手下有N个士兵,分别编号1到N,这些士兵的杀敌数都是已知的。 小工是南将军手下的军师,南将军经常想知道第m号到第n号士兵的总杀敌数,请你帮助小工来回答南将军吧。 南将军的某次询问之后士兵i可能又杀敌q人,之后南将军再询问的时候,需要考虑到新增的杀敌数。 输入 只有一组测试数据 第原创 2017-04-11 18:19:48 · 207 阅读 · 0 评论