题目 一开始有一个双头队列,每次添加一个数(这是数是二的幂,所有数的和不大于\(2^13\)),由你来决定添加到队头还是队尾.如果队列里面相邻的两个数相同,设它们都是\(x\),那么这两个数会合并为\(2x\).问所有数添加完后队列里能否只剩下一个数. 算法 搜索题,但是需要巧妙地记录状态!这种题不可多. 一个显然的是,队列里不会存在相邻的三个数\(a,b,c\),满足\(a>b,c>b\).这样的话,队列肯定是一个倒V字. 记状态\((i,j)\)为添加完前\(i\)个数,\(j\)是倒V左…
题目 给出一棵树,每个节点有一个怪物或血药,遇到怪物必须打,打完后扣掉一定的血量. 一开始英雄的血量为\(0\),当血量小于\(0\)时就挂了. 给出英雄的起点和终点,问能否成功到达终点. 算法 这题的方法真的是太美妙了!感觉ACM的题目比OI的好多了,因为它的程序不长,并且每题都不容易想啊. 我们先来解决一个弱化版问题:把起点作为根,问英雄最多能加多少血. 我们可以想象每个点有一个礼包,这个礼包有两个属性,不妨用\((a,b)\)表示,表示当英雄的血量不少于\(a\)时可以加上\(b\)点血量…
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5015 设dp[cur][i][j]表示当前是第cur个顶点,自身状态是i(0或者1),爸爸的状态是j(0或者1)的时候的最多白色节点数. 0---白色 1---黑色 如果不合法,就是第cur号顶点不能染成白色,则为-1,注意到任意节点都可以染成黑色,所以dp[cur][1][…
Glass Beads Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ID: 554564-bit integer IO format: %lld      Java class name: Main   Once upon a time there was a famous actress. As you may expect, she played most…
One-way traffic Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ID: 266464-bit integer IO format: %lld      Java class name: Main   In a certain town there are n intersections connected by two- and one-way s…
Bring Them There Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ID: 295764-bit integer IO format: %lld      Java class name: Main By the year 3141, the human civilization has spread all over the galaxy. The…
Ladies' Choice Time Limit: 6000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ID: 398964-bit integer IO format: %lld      Java class name: Main Background Teenagers from the local high school have asked you to help them wi…
Dividing coins Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ID: 558364-bit integer IO format: %lld      Java class name: Main It's commonly known that the Dutch have invented copper-wire. Two Dutch men we…
Critical Links Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVALive. Original ID: 529264-bit integer IO format: %lld      Java class name: Main In a computer network a link L, which interconnects two servers, is considered…
Problemsetting Time Limit: 5000ms Memory Limit: 131072KB 64-bit integer IO format: %lld      Java class name: Main Prev Submit Status Statistics Discuss Next Type: None   None   Graph Theory       2-SAT       Articulation/Bridge/Biconnected Component…