
ZOJ
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
【POJ - 1789】【ZOJ - 2158】【SCU - 1832】Truck History (最小生成树)
题干:DescriptionAdvanced 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...原创 2018-07-20 00:04:46 · 312 阅读 · 0 评论 -
【ZOJ - 3946】Highway Project(最短路子图,维护双权值,贪心,最小树形图)
题干:Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from the capital as fast as possible. Thus, he proposed the highway project....原创 2019-04-18 22:19:04 · 455 阅读 · 0 评论 -
【ZOJ - 3872】Beauty of Array(思维,计算贡献,枚举)
题干:Edward has an arrayAwithNintegers. He defines the beauty of an array as the summation of all distinct integers in the array. Now Edward wants to know the summation of the beauty of all contig...原创 2019-04-23 14:45:10 · 190 阅读 · 0 评论 -
【2019浙江省赛 - E】Sequence in the Pocket(思维)
题干:DreamGrid has just found an integer sequencein his right pocket. As DreamGrid is bored, he decides to play with the sequence. He can perform the following operation any number of times (includi...原创 2019-04-27 19:00:49 · 1916 阅读 · 0 评论 -
【ZOJ - 4033】CONTINUE...? (思维,整体思想,分组思想)
题干:DreamGrid hasclassmates numbered fromto. Some of them are boys and the others are girls. Each classmate has some gems, and more specifically, the-th classmate hasgems.DreamGrid would li...原创 2019-04-27 12:27:43 · 377 阅读 · 0 评论 -
【ZOJ - 4032】Magic Points (思维,几何,构造)
题干:解题报告:想到了,这样绕圈构造。但是这样有个问题,最后一个点如何构造。刚开始想的是n=奇数 , 就8 10 这样的连一条,n=偶数 就8 11 这样的连一条,随便构造一下就行,但是发现这样好像不行。所以改了构造方法大概长这样,就是交叉着连,然后如果n=偶数,那会剩下两条边的空闲,那就先2,4这样连一条,3,7这样连一条。如果n=奇数,那就剩下一条...原创 2019-04-27 12:22:45 · 461 阅读 · 0 评论 -
【ZOJ - 4029】Now Loading!!!(整除分块,思维,二分,前缀和)
题干:其中 zi 是第i次询问后的z。解题报告: 因为有取log运算,所以分母的取值肯定不会超过30种,所以分每一个分母的时候,用前缀和优化一个和,最后求乘积就行了。(其实不需要快速幂,用快速幂也可以但是容易出错,因为需要判断如果已经大于1e9了就直接return到一个break的地方,但是wjh大佬强啊!!所以不怂、、)另外这题要注意不能直接一个前缀和求出来之后向下取整...原创 2019-04-27 12:09:33 · 275 阅读 · 0 评论 -
【ZOJ - 4024】Peak(模拟,水题)
题干:A sequence ofintegersis called a peak, if and only if there exists exactly one integersuch that, andfor all, andfor all.Given an integer sequence, please tell us if it's a peak or ...原创 2019-04-27 11:21:02 · 331 阅读 · 0 评论 -
【ZOJ - 3870】Team Formation(异或,思维)
题干:For an upcoming programming contest, Edward, the headmaster of Marjar University, is forming a two-man team fromNstudents of his university.Edward knows the skill level of each student. He ha...原创 2019-04-17 20:45:14 · 221 阅读 · 0 评论 -
【ZOJ - 3778】Talented Chef(贪心)
题干:As we all know,Coach Gaois a talented chef, because he is able to cookMdishes in the same time. Tonight he is going to have a hearty dinner with his girlfriend at his home. Of course,Coach G...原创 2019-04-23 21:43:56 · 303 阅读 · 0 评论 -
【ZOJ - 3780】Paint the Grid Again(拓扑排序,图论,证明性质)
题干:Leo has a grid withN×Ncells. He wants to paint each cell with a specific color (either black or white).Leo has a magical brush which can paint any row with black color, or any column with w...原创 2019-04-23 22:17:11 · 287 阅读 · 0 评论 -
【ZOJ - 2968 】Difference Game (贪心,思维模拟)
题干:Now you are going to play an interesting game. In this game, you are given two groups of distinct integers andCcoins. The two groups, namedGaandGbrespectively, are not empty and contain the ...原创 2019-07-22 20:58:37 · 312 阅读 · 0 评论 -
*【ZOJ - 3703】Happy Programming Contest(带优先级的01背包)
题干:In Zhejiang University Programming Contest, a team is called "couple team" if it consists of only two students loving each other. In the contest, the team will get a lovely balloon with unique co...原创 2019-07-11 22:10:25 · 238 阅读 · 0 评论 -
【2019浙江省赛 - A】Vertices in the Pocket(权值线段树下二分,图,思维)
题干:DreamGrid has just found an undirected simple graph withvertices and no edges (that's to say, it's a graph withisolated vertices) in his right pocket, where the vertices are numbered from 1 t...原创 2019-04-30 11:59:23 · 1215 阅读 · 5 评论 -
*【ZOJ - 3781】Paint the Grid Reloaded(dfs求连通块缩点,bfs求最短路,建图技巧)
题干:Leo has a grid withNrows andMcolumns. All cells are painted with either black or white initially.Two cellsAandBare calledconnectedif they share an edge and they are in the same color,...原创 2019-04-24 20:18:27 · 260 阅读 · 0 评论 -
【2019浙江省赛 - K 】Strings in the Pocket(马拉车,思维)
题干:BaoBao has just found two stringsandin his left pocket, whereindicates the-th character in string, andindicates the-th character in string.As BaoBao is bored, he decides to select a...原创 2019-04-29 12:31:51 · 791 阅读 · 0 评论 -
【ZOJ - 3715】Kindergarten Election(枚举得票数,贪心)
题干:At the beginning of the semester in kindergarten, thenlittle kids (indexed from 1 ton, for convenience) in class need to elect their new leader.Theithkid will vote for his best friendfi(...原创 2019-04-23 14:39:58 · 290 阅读 · 0 评论 -
【ZOJ - 3956】Course Selection System(01背包)
题干:There arencourses in the course selection system of Marjar University. Thei-th course is described by two values: happinessHiand creditCi. If a student selectsmcoursesx1,x2, ...,xm, th...原创 2019-04-19 12:29:35 · 253 阅读 · 0 评论 -
【ZOJ - 3963】Heap Partition (STLset,二叉树的性质,构造,贪心,思维)
题干:A sequenceS= {s1,s2, ...,sn} is calledheapableif there exists a binary treeTwithnnodes such that every node is labelled with exactly one element from the sequenceS, and for every non-ro...原创 2019-04-06 21:57:02 · 456 阅读 · 0 评论 -
【ZOJ - 2949】Coins of Luck (概率dp,期望)
题干:给你两种泡面 各N包,然后你扔硬币,正面朝上吃第一种,反面呢 吃第二种,有任意一种吃完时 就不需要抛硬币了,求停止抛硬币的期望。Sample Input212Sample Output1.002.50解题报告: dp[i][j]代表i包第一种和j包第二种,抛硬币的期望,考虑最后吃的最后一包,于是分别由dp[i-1][j]和dp[i][j-1]等可...原创 2019-03-26 22:24:56 · 262 阅读 · 0 评论 -
【ZOJ - 2972】Hurdles of 110m (dp)
题干:In the year 2008, the 29th Olympic Games will be held in Beijing. This will signify the prosperity of China and Beijing Olympics is to be a festival for people all over the world as well.Liu Xi...原创 2019-03-05 12:23:07 · 295 阅读 · 0 评论 -
【ZOJ - 2969】Easy Task (模拟,数学)
题干:Calculating the derivation of a polynomial is an easy task. Given a function f(x) , we use (f(x))' to denote its derivation. We use x^n to denote xn. To calculate the derivation of a polynomial, ...原创 2019-03-05 09:49:54 · 302 阅读 · 0 评论 -
【POJ - 2976】【ZOJ - 3068】【SCU - 2992】Dropping tests (01分数规划)
题干:In a certain course, you take n tests. If you get ai out of bi questions correct on test i, your cumulative average is defined to be.Given your test scores and a positive integer k, determine...原创 2019-02-18 22:50:32 · 297 阅读 · 0 评论 -
【ZOJ - 2836 】Number Puzzle (容斥原理)
题干:Given a list of integers (A1, A2, ..., An), and a positive integer M, please find the number of positive integers that are not greater than M and dividable by any integer from the given list. ...原创 2018-11-02 15:30:54 · 553 阅读 · 0 评论 -
【ZOJ - 2724】【HDU - 1509】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 syste...原创 2018-08-02 16:40:53 · 234 阅读 · 0 评论 -
ACM竞赛、数论内容常用的定理(求解(a/b)%c,乘法逆元,费马小定理)
如果b与c互素,则(a/b)%c=a*b^((c)-1)%c其中是欧拉函数。或者(a/b)%c=a*b^(c-2)%c如果b与c不互素,则(a/b)%c=(a%bc)/b对于b与c互素和不互素都有(a/b)%c=(a%bc)/b成立乘法逆元用扩展欧几里得定理:例题:ZOJ - 3609题干:The modular modular multiplicative inverse...原创 2018-07-27 20:45:55 · 1812 阅读 · 0 评论 -
【ZOJ - 3210】A Stack or A Queue? (模拟)
题干:Do you know stack and queue? They're both important data structures. A stack is a "first in last out" (FILO) data structure and a queue is a "first in first out" (FIFO) one.Here comes the probl...原创 2018-07-26 00:43:40 · 237 阅读 · 0 评论 -
【ZOJ - 2976】Light Bulbs (枚举,暴力)
题干:Wildleopard had fallen in love with his girlfriend for 20 years. He wanted to end the long match for their love and get married this year. He bought a new house for his family and hired a company...原创 2019-03-05 12:30:09 · 450 阅读 · 2 评论 -
【ZOJ - 3212 】K-Nice (构造)
题干:This is a super simple problem. The description is simple, the solution is simple. If you believe so, just read it on. Or if you don't, just pretend that you can't see this one.We say an elemen...原创 2019-03-08 13:53:53 · 382 阅读 · 0 评论 -
【ZOJ - 2955】Interesting Dart Game(背包,结论,裴蜀定理,数论)
题干:Recently, Dearboy buys a dart for his dormitory, but neither Dearboy nor his roommate knows how to play it. So they decide to make a new rule in the dormitory, which goes as follows:Given a num...原创 2019-03-26 22:12:44 · 269 阅读 · 0 评论 -
*【ZOJ - 3604】Tunnel Network (Cayley定理,purfer数列,无根树定理,构造,结论,或dp)
题干:Country Far-Far-Away is a big country withNcities. But it is now under a civil war. The rebel uses the ancient tunnel network which connects allNcities withN-1 inter-city tunnels for transpo...原创 2019-03-22 19:21:21 · 309 阅读 · 0 评论 -
【ZOJ - 3211】Dream City (01背包类问题,贪心背包)
题干:JAVAMAN is visiting Dream City and he sees a yard of gold coin trees. There arentrees in the yard. Let's call them tree 1, tree 2 ...and treen. At the first day, each treeihasaicoins on it...原创 2019-03-08 13:41:08 · 694 阅读 · 0 评论 -
【ZOJ - 3703】Happy Programming Contest(带优先级的01背包,贪心背包)
题干:In Zhejiang University Programming Contest, a team is called "couple team" if it consists of only two students loving each other. In the contest, the team will get a lovely balloon with unique co...原创 2019-03-08 12:10:05 · 321 阅读 · 0 评论 -
【ZOJ - 3591】Nim(博弈问题,思维,STLmap)
题干:Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. The game ends when one of the players is unable to remove object in his/her turn. This...原创 2019-03-13 22:32:08 · 265 阅读 · 0 评论 -
【ZOJ - 4020 】Traffic Light (bfs,分层图)
题干:n*m矩阵a.若a[i][j]==1则可以往左右走,若a[i][j]==0 则可以往上下走.每一秒可以按上述规则移动,并且每秒钟矩阵所有的值翻转。n*m<=1e5.问从(sx,sy)到(tx,ty)的最短时间.解题报告: 这题因为不带权值所以不需要考虑Dijkstra,可以根据时间直接判断状态是0还是1。如果状态的变换很复杂的话就考虑分层图就好了。AC代码:...原创 2019-03-03 15:38:38 · 339 阅读 · 0 评论 -
【ZOJ - 4019】Schrödinger's Knapsack (dp,背包,贪心,组内贪心组间dp)
题干:有两种物品,k分别为k1,k2,有大小各不一的这两种物品若干,放入容量为c的背包中,能获得求最大的值。放的顺序会影响结果。每次放入一物品,其获得的值都可以用v=kr计算,r表示放入后背包剩下的容量。有两种物品分别为n,m个,每种物品对应价值k1,k2。有一个容量为c的背包,每次将一个物品放入背包所获取的价值为(k1或k2)*放入物品后的剩余体积。求问所获取的最大价值。解题报告:...原创 2019-03-03 15:32:48 · 323 阅读 · 0 评论 -
【ZOJ - 1163】The Staircases(dp)
题干:One curious child has a set of N little bricks. From these bricks he builds different staircases. Staircase consists of steps of different sizes in a strictly descending order. It is not allowed ...原创 2019-03-08 15:16:38 · 403 阅读 · 0 评论 -
【ZOJ - 3329】One Person Game(带循环的概率dp,数学期望,高斯消元,数学)
题干:There is a very simple and interesting one-person game. You have 3 dice, namelyDie1,Die2andDie3.Die1hasK1faces.Die2hasK2faces.Die3hasK3faces. All the dice are fair dice, so the pr...原创 2019-07-28 14:53:49 · 277 阅读 · 0 评论