Travel There are nn planets in the MOT galaxy, and each planet has a unique number from 1 \sim n1∼n. Each planet is connected to other planets through some transmission channels. There are mm transmission channels in the galaxy. Each transmission cha…
Tree Ming and Hong are playing a simple game called nim game. They have nn piles of stones numbered 11 to nn ,the ii-th pile of stones has a_iai​ stones. There are n - 1n−1 bidirectional roads in total. For any two piles, there is a unique path from…
Swap There is a sequence of numbers of length nn, and each number in the sequence is different. There are two operations: Swap the first half and the last half of the sequence (if nn is odd, the middle number does not change) Swap all the numbers in…
Angel's Journey “Miyane!” This day Hana asks Miyako for help again. Hana plays the part of angel on the stage show of the cultural festival, and she is going to look for her human friend, Hinata. So she must find the shortest path to Hinata’s house.…
Tasks It's too late now, but you still have too much work to do. There are nn tasks on your list. The ii-th task costs you t_iti​seconds. You want to go to bed TT seconds later. During the TT seconds, you can choose some tasks to do in order to finis…
链接:https://nanti.jisuanke.com/t/39277 思路: 一开始看着很像树分治,就用树分治写了下,发现因为异或操作的特殊性,我们是可以优化树分治中的容斥操作的,不合理的情况只有当两点在一条链上才存在,那么直接一遍dfs从根节点向下跑途中维护一下前缀和,把所有情况中不合理情况造成的值修正. 这样的话时间复杂度就可以降得非常低了,感觉还可以优化,但是懒得写了 代码耗时:142ms. 实现代码: #include<bits/stdc++.h> using namespace…
今天模拟赛考了一道计蒜客NOIP2017模拟赛(三)day2T3的数三角形,原题链接 https://nanti.jisuanke.com/t/T2202 ,LZOJ3878攻略.场上想了很久都没转化出来,后来觉得这道想法题很妙,记录一下. 题意: 数出一个完全图中完全异色三角形\(\times 3\)-完全同色三角形\(\times 6\)的答案是多少. 解法: 方法一: 转化为:题目本质上是出现同色三角形好感度-9,出现两条边相等另一条不同的三角形好感度-3, 数一数同色角的个数就行了 方法…
计蒜客\(2019CSP\)比赛第二场 巧妙爆零这场比赛(我连背包都不会了\(QWQ\) \(T1\) \(Too\) \(Young\) 大学选课真的是一件很苦恼的事呢! \(Marco\):"我要两年毕业!我要选尽量多的学分!这些课统统选上!" 长者:"你啊,\(Too Young\)!你看看作业量,你做的完吗?" \(Marco\)(笑容逐渐消失\(.gif\)):"那可咋整啊?" 长者:"还能咋整?退课呗!" 已知 \…
又到了一年一度的新生入学季了,清华和北大的计算机系同学都参加了同一场开学考试(因为两校兄弟情谊深厚嘛,来一场联考还是很正常的). 不幸的是,正当老师要统计大家的成绩时,世界上的所有计算机全部瘫痪了. “计算机坏了,可计算机系还得办.小 K,你去了解一下大家的成绩,顺便数数今年两校计算机系有多少人吧!” 于是,小 K 来到了人群中,开始调查大家的成绩. 然而,同学们只有七秒钟的记忆,已经忘记了自己的具体成绩(这可真是尴尬啊). 但是,因为在忘记成绩之前和校友互相调侃过,他们清楚地记得 在自己的学校…
Online Judge:计蒜客信息学3月提高组模拟赛 Label:记搜,TarJan缩点,树状数组,期望Dp 题解 整个题目由毫无关联的两个问题组合成: part1 问题:对于每个询问的起点终点,求出起点到终点能够收获的最大矿石价值. 思路: 1.矿石种类不多,且收获价值时只与是否拥有有关,与收集数量无关,可以用状态压缩表示当前收集矿石的状态: 2.由于是单向边且可能形成环,用\(Tarjan\)缩点,然后进行转移.或者直接记忆化dfs/bfs,用\(dp[i][j][sta]\)表示,从\(…