Adjacent Replacements
第一次打 cf 就做出一道这样的找规律的题,打到自闭。
| |
第一次打 cf 就做出一道这样的找规律的题,打到自闭。
| |
链接:https://www.nowcoder.com/acm/contest/133/A
来源:牛客网
现在有一棵被 Samsara-Karma 染了 k 种颜色的树,每种颜色有着不同的价值,Applese 觉得 Samsara-Karma 染的太难看了,于是打算把整棵树重新染成同一种颜色,但是,由于一些奥妙重重的原因,每一次染色 Applese 可以选择两个有边相连的点,将其中一个染成另一个的颜色。而进行一次这样的操作需要付出两种颜色价值和的代价,
现在,Applese 的钱要用来买书 (game),所以他想要最小化代价
翻译
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 41406 Accepted Submission(s): 23977
The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyzes each plot separately, using sensing equipment to determine whether or not the plot contains oil. A plot containing oil is called a pocket. If two pockets are adjacent, then they are part of the same oil deposit. Oil deposits can be quite large and may contain numerous pockets. Your job is to determine how many different oil deposits are contained in a grid.
假设有一个 n 行 m 列的迷宫,每个单位要么是空地(用 1 表示)要么是障碍物(用 0 表示).
如和找到从起点到终点的最短路径?利用 BFS 搜索,逐步计算出每个节点到起点的最短距离,
以及最短路径每个节点的前一个节点。最终将生成一颗以起点为根的 BFS 树。此时 BFS 可以求出任意一点到起点的距离。
那天晚上报名了没打,第二天早上打的,也只出了两题。
| |
| |
2018 年全国多校算法寒假训练营练习比赛(第二场)B(0 1 背包变化 特殊处理一个物品)
链接:https://www.nowcoder.com/acm/contest/74/B
来源:牛客网
Taotao 的电脑带不动绝地求生,所以 taotao 只能去玩 pc 版的荒野行动了,和绝地求生一样,游戏人物本身可以携带一定重量 m 的物品,装备背包之后可以多携带 h(h 为 0 代表没有装备背包)重量的东西。玩了几天 taotao 发现了一个 BUG,当装备背包之后,如果可携带重量没有满,就可以拿一个任意重的东西(解释看样例)有一天 taotao 空降到了一个奇怪的岛上,岛上有 n 件装备,每个装备都有重量 Wi 和威力值 Vi, 但 taotao 不认识这些装备,所以他来求助你,挑选威力最大的装备,帮助他吃鸡。