02 2020 档案
摘要:有 NN 种物品和一个容量是 VV 的背包。 第 ii 种物品最多有 sisi 件,每件体积是 vivi,价值是 wiwi。 求解将哪些物品装入背包,可使物品体积总和不超过背包容量,且价值总和最大。 输出最大价值。 输入格式 第一行两个整数,N,VN,V,用空格隔开,分别表示物品种数和背包容积。 接
阅读全文
摘要:You are given three integers a≤b≤ca≤b≤c . In one move, you can add +1+1 or −1−1 to any of these integers (i.e. increase or decrease any number by one)
阅读全文
摘要:You want to perform the combo on your opponent in one popular fighting game. The combo is the string ss consisting of nn lowercase Latin letters. To p
阅读全文
摘要:output standard output You are given an array aa of length nn . You are also given a set of distinct positions p1,p2,…,pmp1,p2,…,pm , where 1≤pi<n1≤pi
阅读全文
摘要:You are given two positive integers aa and bb . In one move, you can change aa in the following way: Choose any positive odd integer xx (x>0x>0 ) and
阅读全文
摘要:题目描述 某地临时居民想获得长期居住权就必须申请拿到红牌。获得红牌的过程是相当复杂 ,一共包括NNN个步骤。每一步骤都由政府的某个工作人员负责检查你所提交的材料是否符合条件。为了加快进程,每一步政府都派了MMM个工作人员来检查材料。不幸的是,并不是每一个工作人员效率都很高。尽管如此,为了体现“公开政
阅读全文
摘要:题目背景 栈是计算机中经典的数据结构,简单的说,栈就是限制在一端进行插入删除操作的线性表。 栈有两种最重要的操作,即poppoppop(从栈顶弹出一个元素)和pushpushpush(将一个元素进栈)。 栈的重要性不言自明,任何一门数据结构的课程都会介绍栈。宁宁同学在复习栈的基本概念时,想到了一个书
阅读全文
摘要:You are given a sequence b1,b2,…,bnb1,b2,…,bn . Find the lexicographically minimal permutation a1,a2,…,a2na1,a2,…,a2n such that bi=min(a2i−1,a2i)bi=mi
阅读全文
摘要:After a long party Petya decided to return home, but he turned out to be at the opposite end of the town from his home. There are nn crossroads in the
阅读全文
摘要:Screen resolution of Polycarp's monitor is a×ba×b pixels. Unfortunately, there is one dead pixel at his screen. It has coordinates (x,y)(x,y) (0≤x<a,0
阅读全文
摘要:This is a harder version of the problem. In this version n≤500000n≤500000 The outskirts of the capital are being actively built up in Berland. The com
阅读全文
摘要:问题描述 w星球的一个种植园,被分成 m * n 个小格子(东西方向m行,南北方向n列)。每个格子里种了一株合根植物。 这种植物有个特点,它的根可能会沿着南北或东西方向伸展,从而与另一个格子的植物合成为一体。 如果我们告诉你哪些小格子间出现了连根现象,你能说出这个园中一共有多少株合根植物吗? 输入格
阅读全文
摘要:问题描述 小明正在玩一个“翻硬币”的游戏。 桌上放着排成一排的若干硬币。我们用 * 表示正面,用 o 表示反面(是小写字母,不是零)。 比如,可能情形是:**oo***oooo 如果同时翻转左边的两个硬币,则变为:oooo***oooo 现在小明的问题是:如果已知了初始状态和要达到的目标状态,每次只
阅读全文
摘要:This is an easier version of the problem. In this version n≤1000n≤1000 The outskirts of the capital are being actively built up in Berland. The compan
阅读全文
摘要:Tired of boring office work, Denis decided to open a fast food restaurant. On the first day he made aa portions of dumplings, bb portions of cranberry
阅读全文
摘要:题目描述 选取和不超过S的若干个不同的正整数,使得所有数的约数(不含它本身)之和最大。 输入格式 输入一个正整数S。 输出格式 输出最大的约数之和。 输入输出样例 输入 #1 11 输出 #1 9 说明/提示 样例说明 取数字4和6,可以得到最大值(1+2)+(1+2+3)=9。 数据规模 S<=1
阅读全文
摘要:Description A group of researchers are designing an experiment to test the IQ of a monkey. They will hang a banana at the roof of a building, and at t
阅读全文
摘要:题目大意: 格雷码(Gray Code)是一种特殊的 nn 位二进制串排列法,它要求相邻的两个二进制串间恰好有一位不同,特别地,第一个串与最后一个串也算作相邻。 nn 位格雷码不止一种,下面给出其中一种格雷码的生成算法: 11 位格雷码由两个 11 位二进制串组成,顺序为:00 ,11 。 n+1n
阅读全文
摘要:题目背景 此题为NOIP2005普及组第三题的疯狂版。 此题为纪念LiYuxiang而生。 题目描述 LiYuxiang是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师。为此,他想拜附近最有威望的医师为师。医师为了判断他的资质,给他出了一个难题。医师把他带到一个到处都是草药的山洞里对他说:“孩子
阅读全文
摘要:题目描述 有一个箱子容量为VVV(正整数,0≤V≤200000 \le V \le 200000≤V≤20000),同时有nnn个物品(0<n≤300<n \le 300<n≤30,每个物品有一个体积(正整数)。 要求nnn个物品中,任取若干个装入箱内,使箱子的剩余空间为最小。 输入格式 111个整
阅读全文
摘要:题目描述 金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间金明自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过NNN元钱就行”。今天一早,金明就开始做预算了,他把想买的物品分为两类:主件与附件,附件是从属于某个主件的,下表就是
阅读全文
摘要:题目背景 uim神犇拿到了uoi的ra(镭牌)后,立刻拉着基友小A到了一家……餐馆,很低端的那种。 uim指着墙上的价目表(太低级了没有菜单),说:“随便点”。 题目描述 不过uim由于买了一些辅(e)辅(ro)书,口袋里只剩MMM元(M≤10000)(M \le 10000)(M≤10000)。
阅读全文
摘要:题目描述 鲁宾逊先生有一只宠物猴,名叫多多。这天,他们两个正沿着乡间小路散步,突然发现路边的告示牌上贴着一张小小的纸条:“欢迎免费品尝我种的花生!――熊字”。 鲁宾逊先生和多多都很开心,因为花生正是他们的最爱。在告示牌背后,路边真的有一块花生田,花生植株整齐地排列成矩形网格(如图111)。有经验的多
阅读全文
摘要:题目描述 John的农场在给奶牛挤奶前有很多杂务要完成,每一项杂务都需要一定的时间来完成它。比如:他们要将奶牛集合起来,将他们赶进牛棚,为奶牛清洗乳房以及一些其它工作。尽早将所有杂务完成是必要的,因为这样才有更多时间挤出更多的牛奶。当然,有些杂务必须在另一些杂务完成的情况下才能进行。比如:只有将奶牛
阅读全文
摘要:题目描述 给出一个NNN个顶点MMM条边的无向无权图,顶点编号为1−N1-N1−N。问从顶点111开始,到其他每个点的最短路有几条。 输入格式 第一行包含222个正整数N,MN,MN,M,为图的顶点数与边数。 接下来MMM行,每行222个正整数x,yx,yx,y,表示有一条顶点xxx连向顶点yyy的
阅读全文
摘要:DP: 背包:https://www.luogu.com.cn/problemnew/solution/P1616 图论: SPFA:http://www.sohu.com/a/244179200_100201031 树: 二叉树三种遍历方式:https://www.cnblogs.com/jpfs
阅读全文
摘要:题目描述 在一个神奇的小镇上有着一个特别的电车网络,它由一些路口和轨道组成,每个路口都连接着若干个轨道,每个轨道都通向一个路口(不排除有的观光轨道转一圈后返回路口的可能)。在每个路口,都有一个开关决定着出去的轨道,每个开关都有一个默认的状态,每辆电车行驶到路口之后,只能从开关所指向的轨道出去,如果电
阅读全文
摘要:题目描述 有一个 nnn 个点 mmm 条边的无向图,请求出从 sss 到 ttt 的最短路长度。 输入格式 第一行四个正整数 n,m,s,tn,m,s,tn,m,s,t。 接下来 mmm 行,每行三个正整数 u,v,wu,v,wu,v,w,表示一条连接 u,vu,vu,v,长为 www 的边。 输
阅读全文
摘要:相信大家都听说一个“百岛湖”的地方吧,百岛湖的居民生活在不同的小岛中,当他们想去其他的小岛时都要通过划小船来实现。现在政府决定大力发展百岛湖,发展首先要解决的问题当然是交通问题,政府决定实现百岛湖的全畅通!经过考察小组RPRush对百岛湖的情况充分了解后,决定在符合条件的小岛间建上桥,所谓符合条件,
阅读全文
摘要:题目描述 国防部计划用无线网络连接若干个边防哨所。2 种不同的通讯技术用来搭建无线网络; 每个边防哨所都要配备无线电收发器;有一些哨所还可以增配卫星电话。 任意两个配备了一条卫星电话线路的哨所(两边都ᤕ有卫星电话)均可以通话,无论他们相距多远。而只通过无线电收发器通话的哨所之间的距离不能超过 D,这
阅读全文
摘要:Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside
阅读全文
摘要:题目描述 城市C是一个非常繁忙的大都市,城市中的道路十分的拥挤,于是市长决定对其中的道路进行改造。城市C的道路是这样分布的:城市中有n个交叉路口,有些交叉路口之间有道路相连,两个交叉路口之间最多有一条道路相连接。这些道路是双向的,且把所有的交叉路口直接或间接的连接起来了。每条道路都有一个分值,分值越
阅读全文
摘要:Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year, yifenfei have many people to meet. Especially a
阅读全文
摘要:Now I think you have got an AC in Ignatius.L's "Max Sum" problem. To be a brave ACMer, we always challenge ourselves to more difficult problems. Now y
阅读全文
摘要:大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认为。因为每次当seeyou买了可乐以后,阿牛就要求和seeyou一起分享这一瓶可乐,而且一定要喝的和seeyou一样多。但seeyou的手中只有两个杯子,它们的容量分别是N 毫升和M 毫升 可乐的体积为S (S<101)毫升 (
阅读全文
摘要:One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total
阅读全文
摘要:Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whe
阅读全文
摘要:You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock.
阅读全文
摘要:在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。 Input 输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将
阅读全文
摘要:Gildong owns a bulgogi restaurant. The restaurant has a lot of customers, so many of them like to make a reservation before visiting it. Gildong tries
阅读全文
摘要:Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse
阅读全文
摘要:Being tired of participating in too many Codeforces rounds, Gildong decided to take some rest in a park. He sat down on a bench, and soon he found two
阅读全文
摘要:Ayoub thinks that he is a very smart person, so he created a function f(s)f(s) , where ss is a binary string (a string which contains only symbols "0"
阅读全文
摘要:0.注意爆int有可能是ans+=(long long)a[x]*b*2;像这种语句如果没加(long long)就会升天。 1.看清数据范围,不开long long见祖宗。 2.不要乱用指针。 3.memset不要乱用,可能会T,同时不要用它初始化double数组等等。 4.每个test case
阅读全文
摘要:Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but
阅读全文
摘要:Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array aa of nn non-negative integers. Da
阅读全文
摘要:You are given three strings aa , bb and cc of the same length nn . The strings consist of lowercase English letters only. The ii -th letter of aa is a
阅读全文
摘要:Polycarp wants to assemble his own keyboard. Layouts with multiple rows are too complicated for him — his keyboard will consist of only one row, where
阅读全文
摘要:Your company was appointed to lay new asphalt on the highway of length nn. You know that every day you can either repair one unit of the highway (lay
阅读全文
摘要:You are given a string ss. Each character is either 0 or 1. You want all 1's in the string to form a contiguous subsegment. For example, if the string
阅读全文
摘要:An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to large
阅读全文
摘要:题目描述 CC C国有n n n个大城市和m mm 条道路,每条道路连接这 nnn个城市中的某两个城市。任意两个城市之间最多只有一条道路直接相连。这 mmm 条道路中有一部分为单向通行的道路,一部分为双向通行的道路,双向通行的道路在统计条数时也计为 11 1条。 CC C国幅员辽阔,各地的资源分布情
阅读全文
摘要:Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Be
阅读全文
摘要:Farmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables
阅读全文
摘要:Guy-Manuel and Thomas have an array aa of nn integers [a1,a2,…,an ]. In one step they can add 11 to any element of the array. Formally, in one step th
阅读全文
摘要:Anu has created her own function ff : f(x,y)=(x|y)−y where || denotes the bitwise OR operation. For example, f(11,6)=(11|6)−6=15−6=9. It can be proved
阅读全文
摘要:题目描述 金明今天很开心,家里购置的新房就要领钥匙了,新房里有一间他自己专用的很宽敞的房间。更让他高兴的是,妈妈昨天对他说:“你的房间需要购买哪些物品,怎么布置,你说了算,只要不超过NNN元钱就行”。今天一早金明就开始做预算,但是他想买的东西太多了,肯定会超过妈妈限定的NNN元。于是,他把每件物品规
阅读全文
摘要:题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题。一次素质拓展活动中,班上同学安排做成一个 m 行 n 列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了。幸运的是,他们可以通过传纸条来进行交流。纸条要经由许多同学传到对方手里,小渊坐在矩阵的左上角,坐标
阅读全文
摘要:题目描述 This problem differs from one which was on the online contest. The sequence a1,a2,...,an a_{1},a_{2},...,a_{n} a1,a2,...,an is called increasi
阅读全文
摘要:题目描述 设A和B是两个字符串。我们要用最少的字符操作次数,将字符串A转换为字符串B。这里所说的字符操作共有三种: 1、删除一个字符; 2、插入一个字符; 3、将一个字符改为另一个字符; !皆为小写字母! 输入格式 第一行为字符串A;第二行为字符串B;字符串A和B的长度均小于2000。 输出格式 只
阅读全文
摘要:题目背景 大家都知道,基因可以看作一个碱基对序列。它包含了444种核苷酸,简记作A,C,G,TA,C,G,TA,C,G,T。生物学家正致力于寻找人类基因的功能,以利用于诊断疾病和发明药物。 在一个人类基因工作组的任务中,生物学家研究的是:两个基因的相似程度。因为这个研究对疾病的治疗有着非同寻常的作用
阅读全文
摘要:题目描述 尼克每天上班之前都连接上英特网,接收他的上司发来的邮件,这些邮件包含了尼克主管的部门当天要完成的全部任务,每个任务由一个开始时刻与一个持续时间构成。 尼克的一个工作日为N分钟,从第一分钟开始到第N分钟结束。当尼克到达单位后他就开始干活。如果在同一时刻有多个任务需要完成,尼克可以任选其中的一
阅读全文
摘要:There are nn monsters standing in a row numbered from 11 to nn . The ii -th monster has hihi health points (hp). You have your attack power equal to a
阅读全文
摘要:There is a robot on a coordinate plane. Initially, the robot is located at the point (0,0)(0,0) . Its path is described as a string ss of length nn co
阅读全文
摘要:Mishka wants to buy some food in the nearby shop. Initially, he has ss burles on his card. Mishka can perform the following operation any number of ti
阅读全文
摘要:You are given an array aa consisting of nn integers. In one move, you can choose two indices 1≤i,j≤n1≤i,j≤n such that i≠ji≠j and set ai:=ajai:=aj . Yo
阅读全文
摘要:题意翻译 给定一长度为n的数列,请在不改变原数列顺序的前提下,从中随机的取出一定数量的整数,并使这些整数构成单调上升序列。 输出这类单调上升序列的最大长度。 数据范围:1<=n<=1000001<=n<=1000001<=n<=100000 和On^2算法不同,dp数组存储的不再是子序列长度了,而是
阅读全文
摘要:题目描述 NNN位同学站成一排,音乐老师要请其中的(N−KN-KN−K)位同学出列,使得剩下的KKK位同学排成合唱队形。 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1,2,…,K1,2,…,K1,2,…,K,他们的身高分别为T1,T2,…,TKT_1,T_2,…,T_KT1,T2,
阅读全文
摘要:都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。
阅读全文
摘要:"OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell you an odd number N, and then N integers. There wil
阅读全文
摘要:题目描述 现在请求你维护一个数列,要求提供以下两种操作: 1、 查询操作。 语法:Q L 功能:查询当前数列中末尾L个数中的最大的数,并输出这个数的值。 限制:LLL不超过当前数列的长度。(L>0)(L > 0)(L>0) 2、 插入操作。 语法:A n 功能:将nnn加上ttt,其中ttt是最近一
阅读全文