
【ACM-数据结构】
qq_36424540
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
1289 大鱼吃小鱼
有N条鱼每条鱼的位置及大小均不同,他们沿着X轴游动,有的向左,有的向右。游动的速度是一样的,两条鱼相遇大鱼会吃掉小鱼。从左到右给出每条鱼的大小和游动的方向(0表示向左,1表示向右)。问足够长的时间之后,能剩下多少条鱼?Input 第1行:1个数N,表示鱼的数量(1 <= N <= 100000)。 第2 - N + 1行:每行两个数A[i], B[i],中间用空格分隔,分别表示鱼的大小及游动的方原创 2017-05-29 14:18:57 · 578 阅读 · 0 评论 -
The kth great number
Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the number written by Xiao Ming i原创 2017-07-20 22:44:07 · 376 阅读 · 0 评论 -
B - 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 length Li (1 ≤ Li ≤原创 2017-07-20 22:13:21 · 307 阅读 · 0 评论 -
程序设计:合并数字
蒜头君得到了 nnn 个数,他想对这些数进行下面这样的操作,选出最左边的相邻的差的绝对值为 111 的两个数,只保留较小的数,删去较大的数,直到没有两个相邻的差的绝对值为 111 的数,问最多可以进行多少次这样的操作?输入格式输入第一行为一个整数 n(1≤n≤105)n(1 \leq n \leq 10^5)n(1≤n≤105),表示数字的总数第二行...原创 2018-03-31 23:41:00 · 515 阅读 · 0 评论 -
C - Censor SCU - 4438
Censorfrog is now a editor to censor so-called sensitive words (敏感词).She has a long text p. Her job is relatively simple -- just to find the first occurence of sensitive word wand remove it.frog...原创 2018-05-04 20:33:21 · 14993 阅读 · 0 评论 -
C - Colorful Rainbows ZOJ - 2967 (不得不说,出的数据是真的强,样例都是整数,没看见题目说是real number)
Evelyn likes drawing very much. Today, she draws lots of rainbows on white paper of infinite size, each using a different color. Since there're too many rainbows now, she wonders, how many of them can...原创 2018-05-07 15:39:36 · 210 阅读 · 0 评论 -
算法训练 表达式计算
问题描述 输入一个只包含加减乖除和括号的合法表达式,求表达式的值。其中除表示整除。输入格式 输入一行,包含一个表达式。输出格式 输出这个表达式的值。样例输入1-2+3*(4-5)样例输出-4数据规模和约定 表达式长度不超过100,表达式运算合法且运算过程都在int内进行。#include <cstdio>#include<cstring>#include<...原创 2018-05-21 16:38:36 · 1550 阅读 · 0 评论 -
Common Subexpression Elimination UVA - 12219
点击打开链接#include<bits/stdc++.h>using namespace std;const int maxn=6e4+10;char str[maxn*10],* p;/*map容器的处理规则就是:只要关键比较键值不相等,map就会将此节点添加进map容器里,与其他属性无关。所以如果是只写第一句话的话,只要score想等,就不会比较别的了,所以要注...原创 2018-06-09 21:56:20 · 619 阅读 · 0 评论 -
Naive Operations(区间更新+点更新)
Problem DescriptionIn a galaxy far, far away, there are two integer sequence a and b of length n.b is a static permutation of 1 to n. Initially a is filled with zeroes.There are two kind of ope...原创 2018-07-26 19:52:00 · 260 阅读 · 0 评论 -
Balanced Sequence(栈+贪心排序)[sort的排序]
Problem DescriptionChiaki has n strings s1,s2,…,sn consisting of '(' and ')'. A string of this type is said to be balanced:+ if it is the empty string+ if A and B are balanced, AB is balanced,+ i...原创 2018-07-30 21:03:40 · 251 阅读 · 0 评论 -
Kth number
Problem DescriptionGive you a sequence and ask you the kth big number of a inteval.InputThe first line is the number of the test cases.For each test case, the first line contain two integer n a...原创 2018-08-05 21:37:58 · 637 阅读 · 0 评论 -
A Simple Problem with Integers (叶子节点 循环节)
链接:https://www.nowcoder.com/acm/contest/163/H来源:牛客网 题目描述You have N integers A1, A2, ... , AN. You are asked to write a program to receive and execute two kinds of instructions:1. C a b means p...原创 2018-08-06 21:19:28 · 379 阅读 · 0 评论 -
Glad You Came
Problem DescriptionSteve has an integer array a of length n (1-based). He assigned all the elements as zero at the beginning. After that, he made m operations, each of which is to update an inter...原创 2018-08-07 16:35:05 · 776 阅读 · 0 评论 -
2038: [2009国家集训队]小Z的袜子(hose)
Description作为一个生活散漫的人,小Z每天早上都要耗费很久从一堆五颜六色的袜子中找出一双来穿。终于有一天,小Z再也无法忍受这恼人的找袜子过程,于是他决定听天由命……具体来说,小Z把这N只袜子从1到N编号,然后从编号L到R(L 尽管小Z并不在意两只袜子是不是完整的一双,甚至不在意两只袜子是否一左一右,他却很在意袜子的颜色,毕竟穿两只不同色的袜子会很尴尬。你的任务便是告诉小Z,他有多...转载 2018-08-03 15:30:30 · 103 阅读 · 0 评论 -
G - Sort HDU - 5884(K叉哈夫曼树)
Recently, Bob has just learnt a naive sorting algorithm: merge sort. Now, Bob receives a task from Alice.Alice will give Bob N sorted sequences, and the i-th sequence includes ai elements. Bob need t...原创 2018-08-28 21:33:24 · 206 阅读 · 0 评论 -
Different Integers
链接:https://www.nowcoder.com/acm/contest/139/J来源:牛客网 题目描述Given a sequence of integers a1, a2, ..., an and q pairs of integers (l1, r1), (l2, r2), ..., (lq, rq), find count(l1, r1), count(l2, r2),...原创 2018-09-01 10:41:02 · 188 阅读 · 0 评论 -
最高的奖励
有N个任务,每个任务有一个最晚结束时间以及一个对应的奖励。在结束时间之前完成该任务,就可以获得对应的奖励。完成每一个任务所需的时间都是1个单位时间。有时候完成所有任务是不可能的,因为时间上可能会有冲突,这需要你来取舍。求能够获得的最高奖励。Input 第1行:一个数N,表示任务的数量(2 <= N <= 50000) 第2 - N + 1行,每行2个数,中间用空格分隔,表示任务原创 2017-07-25 10:03:09 · 300 阅读 · 0 评论 -
Windows Message Queue
Message queue is the basic fundamental of windows system. For each process, the system maintains a message queue. If something happens to this process, such as mouse click, text change, the system will原创 2017-07-25 10:17:11 · 199 阅读 · 0 评论 -
Stones
Because of the wrong status of the bicycle, Sempr begin to walk east to west every morning and walk back every evening. Walking may cause a little tired, so Sempr always play some games this time.Ther原创 2017-07-25 10:19:20 · 263 阅读 · 0 评论 -
Battle City (BFS+优先队列)
Many of us had played the game “Battle city” in our childhood, and some people (like me) even often play it on computer now. What we are discussing is a simple edition of this game. Given a map that原创 2017-07-23 00:30:29 · 1315 阅读 · 1 评论 -
LC的课后辅导
描述有一天,LC给我们出了一道题,如图:45660aba95464e61adfbbcc7cea2c44c.jpg这个图形从左到右由若干个 宽为1 高不确定 的小矩形构成,求出这个图形所包含的最大矩形面积。 输入多组测试数据 每组测试数据的第一行为n(0 <= n <= 100), 表示图形有n个小矩形构成 接下来一行输入n个整数h1, h2…hn(0 <= hi <= 1000), 表示每个小原创 2017-07-17 17:39:02 · 451 阅读 · 0 评论 -
Heap Operations
Petya has recently learned data structure named "Binary heap".The heap he is now operating with allows the following operations: put the given number into the heap; get the value of the minimum原创 2017-07-27 10:04:06 · 352 阅读 · 0 评论 -
The Suspects
Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to se原创 2017-07-27 10:01:23 · 217 阅读 · 0 评论 -
Wireless Network
An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the ne原创 2017-07-25 10:14:09 · 433 阅读 · 0 评论 -
Knight Tournament
Hooray! Berl II, the king of Berland is making a knight tournament. The king has already sent the message to all knights in the kingdom and they in turn agreed to participate in this grand event.As for原创 2017-07-25 10:07:38 · 486 阅读 · 0 评论 -
How Many Tables
Today is Ignatius' birthday. He invites a lot of friends. Now it's dinner time. Ignatius wants to know how many tables he needs at least. You have to notice that not all the friends know each other, an原创 2017-07-25 10:05:47 · 215 阅读 · 0 评论 -
Vessels
There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of th原创 2017-07-20 23:23:49 · 544 阅读 · 0 评论 -
Ubiquitous Religions
Petya has recently learned data structure named “Binary heap”. The heap he is now operating with allows the following operations: put the given number into the heap; get the value of the minimum e原创 2017-07-20 22:23:13 · 213 阅读 · 0 评论 -
A - 畅通工程
并查集是我暑假从高手那里学到的一招,觉得真是太精妙的设计了。以前我无法解决的一类问题竟然可以用如此简单高效的方法搞定。不分享出来真是对不起party了。(party:我靠,关我嘛事啊?我跟你很熟么?)来看一个实例,杭电1232畅通工程首先在地图上给你若干个城镇,这些城镇都可以看作点,然后告诉你哪些对城镇之间是有道路直接相连的。最后要解决的是整幅图的连通性问题。比如随意给你两个点,让你判断它们是否连通原创 2017-07-17 21:20:13 · 257 阅读 · 0 评论 -
Passing the Message
What a sunny day! Let’s go picnic and have barbecue! Today, all kids in “Sun Flower” kindergarten are prepared to have an excursion. Before kicking off, teacher Liu tells them to stand in a row. Teache原创 2017-07-27 10:00:30 · 530 阅读 · 0 评论 -
Largest Submatrix of All 1’s
Given a m-by-n (0,1)-matrix, of all its submatrices of all 1’s which is the largest? By largest we mean that the submatrix has the most elements.InputThe input contains multiple test cases. Each test原创 2017-07-25 10:11:22 · 299 阅读 · 0 评论 -
Bad Hair Day
Some of Farmer John’s N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see the top of o原创 2017-07-20 22:39:19 · 265 阅读 · 0 评论 -
Feel Good
Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent people’s memories about some period of life. A new ide原创 2017-07-20 22:30:32 · 417 阅读 · 0 评论 -
C. 痛苦的 01 矩阵 (推公式,树状数组维护)
现有一个 n×n 的 01 矩阵 M。定义 cost(i,j) 为:把第 i 行和第 j 列全部变成 1 最少需要改动多少个元素。定义矩阵的痛苦值 pain(M) 为: pain(M)=(∑i=1n∑j=1n(cost(i,j))2)mod(109+7)要求求出初始矩阵的痛苦值和每次修改操作之后的痛苦值。Input第一行三个正整数 n,k,q (2≤n≤2⋅105, 1...原创 2018-10-06 16:53:37 · 360 阅读 · 0 评论