In 2100, ACM chocolate will be one of the favorite foods in the world.
Standard web browsers contain features to move backward and forward among the pages recently visited. One way to implement these features is to use two stacks to keep track of the pages that can be reached by moving backward and forward. In this problem, you are asked to implement this. The following commands need to be supported: BACK: Push the current page on the top of the forward stack. Pop the page from the top of the backward stack, making it the new current page. If the backward stack is empty, the command is ignored. FORWARD: Push the current page on the top of the backward stack. Pop the page from the top of the forward stack, making it the new current page. If the forward stack is empty, the command is ignored. VISIT : Push the current page on the top of the backward stack, and make the URL specified the new current page. The forward stack is emptied. QUIT: Quit the browser. Assume that the browser initially loads the web page at the URL http://www.acm.org/
Chocolate Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9279 Accepted: 2417 Special Judge Description In 2100, ACM chocolate will be one of the favorite foods in the world. “Green, orange, brown, red…”, colorful sugar-coat
Graveyard Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 1707 Accepted: 860 Special Judge Description Programming contests became so popular in the year 2397 that the governor of New Earck — the largest human-inhabited planet of
该文是有关ACM模板题目的解答,主要描述了如何通过程序判断一个字符串是否可以被划分成一个奶牛场,并计算奶牛场的数目。首先,程序需要确定奶牛场的范围,然后统计符合条件的奶牛场数目。程序通过扫描字符串,判断每个字符是否在奶牛场的范围内,同时统计符合条件的奶牛场数目。最后,程序输出统计结果。
该文章是关于计算字符串的循环节出现的次数以及前缀循环节出现次数的情况。文章使用了动态规划的方法,通过记录字符串中每个字符出现的次数,来计算出循环节和前缀循环节出现次数。同时,对于每个前缀,文章计算了以该前缀开头的所有字符串的循环节出现次数,并记录了出现次数大于1的字符串的前缀。
Accounting for Computer Machinists (ACM) has sufferred from the Y2K bug and lost some vital data for preparing annual report for MS Inc. All what they remember is that MS Inc. posted a surplus or a deficit each month of 1999 and each month when MS Inc. posted surplus, the amount of surplus was s and each month when MS Inc. posted deficit, the deficit was d. They do not remember which or how many months posted surplus or deficit. MS Inc., unlike other companies, posts their earnings for each consecutive 5 months during a year. ACM knows that each of these 8 postings reported a deficit but they do not know how much. The chief accountant is almost sure that MS Inc. was about to post surplus for the entire year of 1999. Almost but not quite.
本文讨论了如何使用字符串的动力学性质来研究字符串的复杂度。首先,作者介绍了字符串动力学的概念和性质,并说明如何通过计算字符串的动力学性质来研究字符串的复杂度。接着,作者详细讲解了如何使用字符串的动力学性质来研究字符串的复杂度,包括计算字符串的动力学性质的方法和步骤。最后,作者通过一个示例来说明如何使用字符串的动力学性质来研究字符串的复杂度,并给出了计算字符串的动力学性质的具体方法和步骤。
看来我的搜索真的很烂,简单的搜索都搞定的这么痛苦 题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=1724 题目大意是输入 拥有钱数,城市数,路
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=1720 这题纯计算几何就搞定了,开始我写了个很长很长的代码,但是Wa掉,也不知道是代码那里有疏漏还
链接: http://acm.pku.edu.cn/JudgeOnline/problem?id=1141 题目意思是输入一些括号,补充括号使之成为没有错误的括号就是只能有括号组在括号组里面,不能出
本文讨论了一种基于模式匹配的字符串计数算法及其实现,并给出了相关的代码。该算法使用KMP算法进行模式匹配,并利用一个前缀数组来加速匹配过程。该算法的时间复杂度为O(n),其中n为字符串的长度。
本文讨论了《POJ-2096-Collecting Bugs》一文中,ACM 模板的使用方法以及代码实现。通过使用该模板,可以在输入的字符串中自动收集和计算错误信息,从而快速解决问题。
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=3277 线段树+离散化 ACM预选赛过去了,可是我们队什么都没拿到,这给我们的打击是相当大的,这也
题目链接: http://acm.pku.edu.cn/JudgeOnline/problem?id=2976 0-1分数规划 最优比例生成树 迭代法 证明:(前几次都是看别人的,这次自己证明) 对于
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=2728 和3757一样都是01分数规划的题,不同的是3757是用的二分,这里用的是Prim 0-1
3636 Nested Dolls 题目链接:[http://acm.pku.edu.cn/JudgeOnline/problem?id=3636 ](http://acm.pku.edu.cn/Ju
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 network were all broken. The computers are repaired one by one, and the network gradually began to work again. Because of the hardware restricts, each computer can only directly communicate with the computers that are not farther than d meters from it. But every computer can be regarded as the intermediary of the communication between two other computers, that is to say computer A and computer B can communicate if computer A and computer B can communicate directly or there is a computer C that can communicate with both A and B.
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=3757 题目大意 第一行输入n,k,f表示从n个服务器里选k个,传输大小为f(以Mb为单位)的文件
该文介绍了计算某个数组的最大子序列和的算法,通过一个二维数组来表示状态转移过程,利用快速幂运算优化算法,并使用二分查找的方法确定所求子序列,最后给出了示例以及代码。
本文讨论了一种ACM模板,用于寻找字符串中第一个不重复的字符,并给出了具体的实现代码。该模板使用滑动窗口的方法,通过记录每个窗口内字符的出现次数,来快速判断第一个不重复的字符。该模板在处理大型字符串时具有较好的性能,并且可以通过扩展来支持更多功能。"
今天心情好,刷了两到ACM水题,思路很简单都在注释里,所以直接贴代码: /** * @file 龟兔赛跑.cpp * @brief 龟兔赛跑 AC代码 (DP) * DP方程式: [到第i的充电
题目链接:http://poj.org/problem?id=1028 我的相同博文参考:https://blog.csdn.net/qq_21201267/article/details/8893
题目链接http://acm.pku.edu.cn/JudgeOnline/problem?id=2549 这道题伤了我很久脑筋 因为是a+b+c=d,数据量是1000,很自然地想到a+b=d-c 这
这道题是我专门为了了解和学习树状数组而写的 这题用树状数组记录翻转次数,然后mod一个2,也可以不断地取反 还要用到二维的树状数组.于是我专门写了个模板用 题目链接:http://acm.pku.ed
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=3513 题目大意是输入树状的家庭关系,问怎么买票(买家庭票还是个人票)最省钱并且票的数量最少 这道
该文介绍了如何通过Dilworth算法来解决最长递增子序列问题,并给出了具体的实现步骤和代码示例。同时,还介绍了如何利用该算法来解决资源调度问题,并给出了一个具体的例子。该算法的时间复杂度为O(n^2),其中n为整数,空间复杂度为O(n^2)
上一个专题是动态规划,然而因为动态规划种类繁多,只能蜻蜓点水每个知识点写一个入门题。如果每个知识点写得比较深入会极为耗时,因此公众号的专题还是只能作为入门用途,尽可能多的写不同的知识点。
比较水的题,数据量暴力可破,但是你以为这样就结束了吗? 如果数据量大一点呢?不得不说,平时做题还是应该深入一点。 我是在写二维线段树找手感的时候做到这题的,顺势就写了,虽然烦了一点,但是加深了对二维线段树的理解。 不会四分树,只会树套树,洋洋洒洒3500B的代码 /**************************************************** file name: 1656.cpp author: huangjipeng creat time: 2014年09
Poj第1083题–Moving Tables 原题 Moving Tables Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each on the north side and south side along the corridor
状态压缩+DP 1972的增强版 题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=2596 题意是给出小于10个的骰子,要求竖着叠成一条,而且每两个
从本篇开始,准备做一系列的专题讲解,主要参考《算法竞赛入门经典》、《算法竞赛进阶指南》两本书。主要是为了能够更加系统的讲解各个知识点,这两本书已经讲得很好了,建议准备ACM学习以及想深入学习算法的同学购买。
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1 Accepted: 1 有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=3631 我讨厌这么长的题目 这题是模拟那个Hash算法,有点像我之前转载的那篇文章里提到的Hash
我踩过的坑全部都写在注释里面了,供大家参考。 #include <stdio.h> #include <algorithm> #include <math.h> #include <string.h> //据说缺了这个会导致某些编译器出错 using namespace std; int N,H,R,T; double height[105]; //目前所有double变量最一开始我都用的是float,导致一直wrong answer 后来发现float会损失精度,ACM还是尽量用double doub
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=3659 这题不算难题了,基本算是中等题 题目大意是给出一颗树,在一些点建一个信号塔,信号塔覆盖范围
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=2446 这是一道匹配题,把行数(r)和列数(c)按(r+c)%2分成两组,然后连边,做一次二分图匹
写这题的目的是看完了zzy的论文,写了半平面交,验证一下正确性,结果发现我写的问题还是很多的。
Brackets My Tags (Edit) Source : Stanford ACM Programming Contest 2004 Time limit : 1 sec Memory limit : 32 M Submitted : 188, Accepted : 113 5.1 Description We give the following inductive definition of a “regular brackets” sequence:
南亚发生了一次地震。ACM (Asia Cooperated Medical 亚洲联合医疗队) 已经为膝上型电脑搭建了一个无线网络,但受到了一次不可预知的余震攻击,因此网络中的所有电脑都被破坏了。电脑被逐台修复,网络逐步恢复了工作。由于受到硬件的约束,每台电脑只能与距离它不超过 d 米的其它电脑直接通信。但每台电脑可被看作其它两台电脑的通信中转点,也就是说,如果电脑 A 和电脑 B 可以直接通信,或存在一台电脑 C 既可与 A 也可与 B 通信,那么电脑 A 和电脑 B 之间就能够通信。
Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its own code describing each type of a truck. The code is simply a string of exactly seven lowercase letters (each letter on each position has a very special meaning but that is unimportant for this task). At the beginning of company's history, just a single truck type was used but later other types were derived from it, then from the new types another types were derived, and so on. Today, ACM is rich enough to pay historians to study its history. One thing historians tried to find out is so called derivation plan -- i.e. how the truck types were derived. They defined the distance of truck types as the number of positions with different letters in truck type codes. They also assumed that each truck type was derived from exactly one other truck type (except for the first truck type which was not derived from any other type). The quality of a derivation plan was then defined as
题目链接: http://acm.pku.edu.cn/JudgeOnline/bbs?problem_id=2528 这题又是线段树+离散化 慢慢的对离散化有点感觉了,但是这题我还是错了3次 题目大
Description 7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体。 设从下往上数第i(1 <= i <= M)层蛋糕是半径为Ri, 高度为Hi的圆柱。当i < M时,要求Ri > Ri+1且Hi > Hi+1。 由于要在蛋糕上抹奶油,为尽可能节约经费,我们希望蛋糕外表面(最下一层的下底面除外)的面积Q最小。 令Q = Sπ 请编程对给出的N和M,找出蛋糕的制作方案(适当的Ri和Hi的值),使S最小。 (除Q外,以上所有数据皆为正整数) Input 有两行,第一行为N(N <= 10000),表示待制作的蛋糕的体积为Nπ;第二行为M(M <= 20),表示蛋糕的层数为M。 Output 仅一行,是一个正整数S(若无解则S = 0)。 Sample Input 100 2 Sample Output 68 Solution 由于深度一定(m),所以使用深度优先搜索,自上而下的设定蛋糕序号,最顶层的为第1层,……,最底层的蛋糕为第m层,很明显满足题目条件的前i层的(从顶层(也就是编号为1的层)开始计数)最小面积mins[i]和体积minv[i]是在该层的半径以及高度都为i时取得,如果采用一般的神搜肯定会超时,所以这题还需要剪枝,剪枝条件有(从m层向上搜,假设前level层的体积为v,面积为s,当前所得的最小面积为best): 1>因为前level层的体积为v,如果剩下的几层的体积都取最小可能值,总体积还是比n大,那么则说明前level层的方案不可行,所以可以剪枝(剪枝条件为:v+minv[dep-1]>n) 2>因为前level层的面积为s,如果剩下的几层的面积都取最小可能值,所得的面积和比已经得到的所求的最小面积best大,也可以进行剪枝(剪枝条件为:s+mins[dep-1]>best) 3>因为前level层的体积为v,那么剩余的m-level层的体积满足:n-v=(hk+……+hm)(k=level+1,……,m) 而剩余部分的表面积满足:lefts=2*(r[k]h[k]+……+r[m]h[m])>2(n-sv)/r[level] (k=level+1,……,m) 显然有上述不等式lefts=best-s>2(n-)/r,即2*(n-v)/r+s
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=1986 这是一道并查集+树的题,采用Tarjan离线算法 首先BS一下出题的人,也太懒了吧,还要我
上一篇我们做了一道棋子摆放的题目,采用的是DFS算法,本篇是一篇BFS算法,在刚开始学习搜索算法的时候,会觉得DFS和BFS算法非常相似,因为都是搜索然后得到结果。
炮兵阵地 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 22654 Accepted: 8774 Description 司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用”H” 表示),也可能是平原(用”P”表示),如下图。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围如图中黑色
Number Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3432 Accepted: 1399 Description Christine and Matt are playing an exciting game they just invented: the Number Game. The rules of this game are as follows. The players
题目链接: http://acm.pku.edu.cn/JudgeOnline/problem?id=2826 大致意思是给你两条线段,问组成的开口向上的V形区域能盛多少雨水。雨水是垂直落下的。 显
The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a refrigerator.
领取专属 10元无门槛券
手把手带您无忧上云