【题解】2020牛客暑期多校训练营(第一场)

B-Suffix Array

• Let C_i = min_{j > i and s_j = s_i} {j - i}
• The B-Suffix Array is equivalent to the suffix array of C_1 C_2 ... C_n
• Detailed proof can be found in “Parameterized Suffix Arrays for Binary Strings • ” http://www.stringology.org/event/2008/p08.html

Infinite Tree

• First, compute the “virual tree” of {1!, 2!, ..., n!}
• Second, to compute the actual cost, use Segment Tree or Fenwick Tree.
• O(m log^2 m)

Domino

• See “Distances in Domino Flip Graphs”
图片说明

Quadratic Form

• The answer is b^T A^{-1} b, which can be proved by Lagrange Duality.
• All we need is to compute the inverse matrix of the matrix A.

Counting Spanning Trees

• The number of spanning trees is prod_{i >= 2} deg(x_i) deg(y_i)
• Detailed proof can be found in “Enumerative properties of Ferrers graphs”
https://arxiv.org/pdf/0706.2918.pdf

Infinite String Comparision

• Compare the string a^{infty} and b^{infty} directly
• By the Periodicity Lemma, if there is no mismatches in the first a + b - gcd(a, b) characters, the two string are identical

BaXianGuoHai, GeXianShenTong

• For simplicity, we denote the multiplication as +, and exponentiation as *
• Precompute B_{i, j} = 2^ {W * j} * v_i
• To compute sum_{i, j} (sum e'{i, j} * 2^{W * j}) v_i
• = sum_x x sum
{i, j} [e'{i, j} = x] B{i, j} = sum_x x Q_x
• To compute sum_x x Q_x • = sum_x (sum_{y >= x} Q_y)
• The overall complexity is O(nm / W + 2^W) • Taking W = 16 yields a fast enough solution

Minimum-cost Flow

• We denote the cost in a network with capacity c and flow f as cost(c, f).
• cost(c, 1) = cost(c * 1/c, 1 / c) * c = cost(1, 1 / c) * c
• For a network with unitary capacity, its cost grows linearly with the flow f, with at most O(m) pieces.
• Thus, we can compute O(m) pieces first, and query in O(log m) time.

1 or 2

• For an edge e=(x, y) where d_x = d_y = 2, add the following edges:
• (x, e) (x', e)
• (y, e') (y', e')
• (e, e')
• The problems is turned into to find a perfect matching in a general graph, which can be solved with Edmond's Algorithm.

Easy Integration

• The value is (n!)^2 / (2n+1)!
• Detailed proof can be found in “Wallis' integrals”.
https://en.wikipedia.org/wiki/Wallis%27_integrals

欢迎参加题解征集活动,补题写题解,即可得牛币 https://ac.nowcoder.com/discuss/450239

全部评论
去年做叉姐出的题自闭,过了一年仍然自闭  
5 回复 分享
发布于 2020-07-12 17:45
题目看不懂就罢了,题解也看不懂,嘤嘤嘤😫
3 回复 分享
发布于 2020-07-12 17:54
为什么不整中文英文两份题解???
2 回复 分享
发布于 2020-07-12 19:47
题解也是英文的🙃
2 回复 分享
发布于 2020-07-12 17:14
尝试阅读,阅读失败
1 回复 分享
发布于 2020-07-13 11:39
这是欺负英语羸弱
1 回复 分享
发布于 2020-07-12 17:17
怎么都是英语儿呀,为啥呀😥
点赞 回复 分享
发布于 2020-07-13 08:43
请问视频在哪啊  群也满了  有点无语😥
点赞 回复 分享
发布于 2020-07-12 19:16
萌新感到了压力QAQ
点赞 回复 分享
发布于 2020-07-12 17:16

相关推荐

xdm 早上喝奶茶差点喷出来。事情是这样的,我们班有个哥们儿,简称 L,去年秋招拿了字节sp,专业方向是后端。我们当时都震惊:这哥们儿平时课上从来不发言,期末小组作业基本是划水的那种,刷题平台 commit记录我点进去看过,绿格子稀稀拉拉。但他面试一路绿灯。一面二面三面 hr 面,全过,给的还是sp。当时班级群里恭喜他的、问他经验的、约饭的,热闹了一周。他说自己"运气好,准备充分"。我们都信了,直到三月初他入职。入职第二周开始,班里另一个进字节的同学W(在隔壁组的)开始跟我他的不对劲。一开始是写代码慢,后来写不出来,再后来是组里 mentor 让他fix 一个简单 bug 都搞了一下午没动静。最离谱的是上周。W 说他们大部门搞了个新人分享会,让新人讲一下自己负责模块的设计思路。L 上去讲了 20分钟,全程念稿子,问答环节别人随便问一个"那你这里为什么用 Redis 不用 Memcached",他直接卡 30秒说"这个我回去再确认一下"。会后他 mentor 直接找 leader 谈,leader 找 hr 谈,hr调出了他面试录像,全程对比口型和回答节奏,发现他二三面有大量时长在偷偷看屏幕外(推测开了双机位 AI 答题)。(这段是 W后来转述给我的,他自己也是听他组里同事八卦来的)昨天下班前,W 告诉我L 被辞退了,让他自己走,不走就走仲裁但会发函到学校。L 现在已经回学校了,朋友圈仅三天可见。我说真的,我不是个心眼小的人,但是我看到这个消息的时候真的有种"嗯,挺好"的感觉。去年秋招我投字节后端,简历挂。我准备了八个月,背 八股 + 刷 500 题 +项目改了三版,连面试机会都没拿到。班里这哥们儿凭着一个外挂上岸,最后还是被甩出来了。不是说作弊就一定会被发现,但是当面试拿到的 offer远远超出真实能力的时候,迟早会有这一天。试用期三个月不是给你过家家的,是真的要写代码、要在会议上回答问题、要扛需求的。我现在反而有点同情他。同情他相信"上岸就是终点"。发出来不是为了嘲笑谁,就是想说给那些正在被身边作弊上岸的同学搞得很 emo 的 uu 们听——别急,回旋镖很长,但它一定会回来。你继续刷你的题,写你的项目,背你的八股。该是你的迟早是你的,不是你的早晚还得还回去。xdm 共勉。
牛客12588360...:我不想评论面试方式,作弊是绝对不对的,但是你八股加刷题也不过是个做题小子,他穿帮纯粹是他菜,你也没有高明到哪里去
点赞 评论 收藏
分享
评论
1
12
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务