[Problem Description] Problem On the game show The Last Word, the host begins a round by showing the contestant a string S of uppercase English letters. The contestant has a whiteboard which is initially blank. The host will then present the contesta…
链接 Google Codejam 2016 Round1A Problem C BFFs 题意 n个小朋友要坐成一个圈.每个小朋友心中都有一个Best Friend Forever.要保证每个人的左右至少有一个是他的BFF,问最多能让多少人做成一个圈. 思路 n只有1000,每个点的出度也都是1.看上去就不需要套用某种算法.综合的考虑一下,如果有m个人的BFF关系正好形成一个环,那么他们就可以成为一种结果,并且这个环中不能有别的人插入了.另外一种情况就是一条链,在这条链中有至少两个点A和B的B…
HYNB Round 8: 2016 ICPC Amritapuri Regionals A - Tim and BSTs 做法 经典的树 DP 问题. \(dp[u][i]\) 表示考虑以 u 为根子树,u 的 rank 为 i 方案数. 关于 \(dp[u][]\) 的计算,枚举左子树有几个比根小的,枚举右子树有几个数字比根小.合并两棵子树的复杂度为 \(O(sz_1 * sz_2)\),因此可以 \(O(n^2)\) 计算答案. B - A Historic Discussion 做法 每…
题目链接:https://code.google.com/codejam/contest/4224486/ Problem A. Mushroom Monster 这题题意就是,有N个时间点,每个时间点,Kaylin可以吃掉一定数量的mushroom,Bartholomew可以放入任意数量的mushroom. 现在给出N个时间点分别有多少mushroom. 问:若Kaylin每个时间点可以吃任意数量的mushroom,那为了配合每个时间点的mushroom,Kaylin最少要吃掉多少蘑菇. 问:…
https://code.google.com/codejam/contest/544101/dashboard#s=p0     Problem In the exciting game of Join-K, red and blue pieces are dropped into an N-by-N table. The table stands up vertically so that pieces drop down to the bottom-most empty slots in…
Problem A. Minimum Scalar Product   This contest is open for practice. You can try every problem as many times as you like, though we won't keep track of which problems you solve. Read the Quick-Start Guide to get started. Problem You are given two v…
Problem You are waiting in a long line to get a haircut at a trendy barber shop. The shop has B barbers on duty, and they are numbered 1 through B. It always takes the kth barber exactly Mk minutes to cut a customer's hair, and a barber can only cut…
题目描述: 原题是纯英文,大意是:你每天可以选择一门课去学习,选题和提交答案.题目为Coding或者Jamming.选的题目如果和老师选的一致,提交答案也匹配,最后可以得10分,若选题不一致只能得5分.若提交答案不一致要扣五分.求最大的得分总和. 题目样例: input: 5CCJJCCJJCJCJJCCJCCCCCC output: Case #1: 20Case #2: 20Case #3: 10Case #4: 20Case #5: 30 解题思路:把问题化为用栈可以解决的括号匹配问题.可…
题意:有R个机器人,去买B件商品,有C个收银员,每个收银员有能处理的商品数量上限mi,处理单件商品所需的时间si,以及最后的装袋时间pi. 每个收银员最多只能对应一个机器人,每个机器人也最多只能对应一个收银员. 让你给每个机器人安排他购买的商品数,以及对应哪个机器人,问你最少需要多长时间才能买回所有商品. 二分答案lim,将收银员按照min(m[i],(lim-p[i])/s[i])(此即为该收银员在当前限制下能处理的商品数)从大到小排序,贪心加入,看是否满足即可. #include<cstdi…
题意:给你一个矩阵,有些点是黑的,让你横切h刀,纵切v刀,问你是否能让切出的所有子矩阵的黑点数量相等. 设黑点总数为sum,sum必须能整除(h+1),进而sum/(h+1)必须能整除(v+1). 先考虑横行,贪心地扫过去,如果到了某一行,当前统计的黑点数恰好为sum/(h+1),就在这里切一刀,接着统计.否则,如果>sum/(h+1),则无解.在这个过程中,每一行被切到哪一横组里就确定了. 然后纵切,过程跟横切类似,只不过统计的不是一个变量,而是一个大小为(h+1)的数组,如果到了某一列,当前…