2019 沈阳网络赛 Fish eating fruit】的更多相关文章

这题看了三个月,终于过了,第一次看的时候没学树形DP,想用点分治但是不会 后来学了二次扫描,就有点想法了.... 这东西也真就玄学了吧... #include<iostream> #include<cstring> #include<vector> #include<algorithm> using namespace std; typedef long long ll; const int maxn = 1e5 + 7; const ll mod = 1e…
链接: https://nanti.jisuanke.com/t/41403 题意: State Z is a underwater kingdom of the Atlantic Ocean. This country is amazing. There are nn cities in the country and n-1n−1 undirected underwater roads which connect all cities. In order to save energy and…
题目传送门 题意:求一颗树中所有点对(a,b)的路径长度,路径长度按照模3之后的值进行分类,最后分别求每一类的和 分析:树形DP \(dp[i][j]\) 表示以 i 为根的子树中,所有子节点到 i 的路径长度模3等于 j 的路径之和 \(c[i][j]\) 表示以 i 为根的子树中,所有子节点到 i 的路径长度模3等于 j 的点数 \(ok[i][j]\) 表示以 i 为根的子树中,是否有子节点到 i 的路径长度模3等于 j 每次只考虑所有经过根 x 的路径,并且路径的一个端点在 x 的一颗子…
https://www.cnblogs.com/31415926535x/p/11520088.html 啊,,不在状态啊,,自闭一下午,,都错题,,然后背锅,,,明明这个简单的题,,, 这题题面不容易看懂,,大致意思是给你一张图,,然后从1节点开始可以任意的走,, 有些节点是 monster 节点,,这样的节点总共只能走一次,,其他的点有一个糖果,问最大的取得糖果的期望 解法很简单,,先求出从1可以不经过 monster 的点的个数,,也就是1的联通块,, 然后对于每一个和1联通块的 mons…
题目链接 题意为求出树上任意点对的距离对3取余的和. 比赛上听到题意就知道是点分治了,但是越写越不对劲,交之前就觉得会T,果不其然T了.修修改改结果队友写了发dp直接就过了Orz. 赛后想了想维护的东西太脑残了,以为像洛谷板子题一样暴力维护就可以,实则被卡死. 赛后的想法是维护距离当前重心的距离对3取余后的距离和以及个数.然后统计的时候枚举两个点的距离取余值,然后统计贡献. 注意下传的时候要消除重复的贡献. 代码丑陋请见谅QAQ #include<bits/stdc++.h> using na…
这道题让我差点怀疑自己高考没考过物理 题意中 he measures the resistance of any two endpoints of it, the resistance values are all 2a2a2a 指的是在三角形中电阻为 2a2a2a 而不是边上的电阻为 2a2a2a 实际上每条边的电阻R为 1R+12R=2a\frac{1}{R} + \frac{1}{2R} = 2aR1​+2R1​=2a 可以求得R=3aR = 3aR=3a 所以可以得到递推公式 an+1=…
https://nanti.jisuanke.com/t/41403 2019沈阳网络赛D题 树形dp.一棵树,求任意两个点的距离之和.u-v和v-u算两次.两点之间的距离分为三类,模3等于0,1,2三类,最后输出这三类的总和. 第一种方法.直接累加.遍历到一个点的时候.先计算答案.答案加上所有已经遍历过得点到他的距离之和.同时该点也要加上这个值,同时要加上数量.每次先搜到底统计往下遍历的值,然后回溯的时候统计 回溯的值.因为每次只计算了之前的点到他的距离之和,所以最后的结果要乘以2,因为u-v…
Fish eating fruit \[ Time Limit: 1000 ms \quad Memory Limit: 262144 kB \] 题意 大体的题意就是给出一棵树,求每一对点之间的距离,然后把该距离存在距离 \(\mod 3\) 的位置,输出总和. 思路 令两个 \(dp\) 数组和两个辅助 \(dp\) 的数组. \(dp1[i][j]\) 表示从 \(i\) 为起点往下到各个点距离 \(\mod 3\) 后为 \(j\) 的距离总和. \(cnt1[i][j]\) 表示以 \…
2018 ICPC 沈阳网络赛 Call of Accepted 题目描述:求一个算式的最大值与最小值. solution 按普通算式计算方法做,只不过要同时记住最大值和最小值而已. Convex Hull 题目描述:定义函数\(gay(x)\),若\(x\)是某个非\(1\)的数的平方的倍数,则\(gay(x)=0\),否则\(gay(x)=x^2\),求\(\sum_{num=1}^{n} ( \sum_{i=1}^{num} gay(x) ) mod p\) solution \[\sum…
题意:询问区间有多少个连续的段,而且这段的颜色在[L,R]才算贡献,每段贡献是1. 有单点修改和区间查询. 思路:46min交了第一发树套树,T了. 稍加优化多交几次就过了. 不难想到,除了L这个点,其他的点都可以只统计这一段的段首.把位置看成x,颜色看成y,就成了二维平面就矩形内点的个数,这就是裸的树套树或者CDQ了. 树套树:34**ms. /* 2019南昌网络赛I. 询问区间有多少个连续的段,而且这段的颜色在[L,R]才算贡献,每段贡献是1. 有单点修改和区间查询. 也可以CDQ来做,常…
ACM-ICPC 2019南昌网络赛I题 Yukino With Subinterval 题目大意:给一个长度为n,值域为[1, n]的序列{a},要求支持m次操作: 单点修改 1 pos val 询问子区间中某个值域的数的个数,连续的相同数字只记为一个.(即统计数字段的个数) 2 L R x y 数据范围: 1 ≤ n,m ≤ 2×10^5 1 ≤ a[i] ≤ n 解题思路: 连续重复的数字只记一次.所以考虑将每个数字段除第一个出现外的数字都删去(记为0).在读入操作的时候暴力模拟,同时维护…
ICPC 2019 徐州网络赛 比赛时间:2019.9.7 比赛链接:The Preliminary Contest for ICPC Asia Xuzhou 2019 赛后的经验总结 // 比赛完才反应过来没看完全部题, J题树形dp没写太亏了... // 几何旋律AK了,太强了Orz // 虽然我们队A了8题,但如果时间分配好,认真读题避免看错题的话,应该至少多A一题 A. Who is better? 题意 两个人玩游戏,谁先消灭完敌人就赢.两条规则:1. 第一个人不能全部消灭完: 2.…
"Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a bipartite graph is a fantastic graph. He has two fantastic numbers, and he wants to let all the degrees to between the two boundaries. You can pick up sev…
ACM-ICPC 南昌网络赛F题 Megumi With String 题目描述 给一个长度为\(l\)的字符串\(S\),和关于\(x\)的\(k\)次多项式\(G[x]\).当一个字符串\(str\)是S的子串时,定义\(str\)的\(value\)值为\(G[length(str)]\),否则\(value=0\).一个字符串的\(power\)值定义为其所有子串的\(value\)之和.每次向\(S\)末尾添加一个字符,重复\(m\)次.求每次添加字符后,一个长度为\(n\)的随机串\…
南京网络赛自闭现场 https://nanti.jisuanke.com/t/41298 二维偏序经典题型 二维前缀和!!! #include<bits/stdc++.h> using namespace std; #define int long long #define sc(x) scanf("%lld",&x); int T; #define P pair<int,int> #define fi first #define se second #…
题意 分别算一个树中所有简单路径长度模3为0,1,2的距离和乘2. 分析 记录两个数组, \(dp[i][k]\)为距i模3为k的子节点到i的距离和 \(f[i][k]\)为距i模3为k的子节点的个数 \(ans[k]\)为所有简单路径长度模3为k的距离和 \(v\)是\(u\)的儿子,\(c\)是u到v的边长度,\(0<i,j<3,k=(j-c\%3+3)\%3\) \(dp[u][(i+c\%3)\%3]+=dp[v][i]+f[v][i]*c\) \(f[u][(i+c\%3)\%3]+…
Problem Similar to the strange ability of Martin (the hero of Martin Martin), Ghh will random occurrence in one of \(N\) cities every morning and the money will change to \(X\) RMB (No matter how much money had yesterday). Ghh finds that every \(N\)…
题意:求一棵树上所有路径和模3分别为0 1 2 的权值的和 思路:树形dp 增加一个记录儿子节点满足条件的个数的数组 不要放在一起dp不然答案跟新会有问题 #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-6; const int N = 2e4+7; typedef long long ll; const ll mod = 1e9+7 ; using…
Given a rooted tree ( the root is node 11 ) of NN nodes. Initially, each node has zero point. Then, you need to handle QQ operations. There're two types: 1\ L\ X1 L X: Increase points by XX of all nodes whose depth equals LL ( the depth of the root i…
One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. However, Pucci the father somehow knows it and wants to stop her. There are NN spots in the jail and MM roads connecting some of the spots. JOJO finds that Pucci kn…
17.64% 1000ms 131072K   A sequence of integer \lbrace a_n \rbrace{an​} can be expressed as: \displaystyle a_n = \left\{ \begin{array}{lr} 0, & n=0\\ 2, & n=1\\ \frac{3a_{n-1}-a_{n-2}}{2}+n+1, & n>1 \end{array} \right.an​=⎩⎨⎧​0,2,23an−1​−an−…
"Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a bipartite graph is a fantastic graph. He has two fantastic numbers, and he wants to let all the degrees to between the two boundaries. You can pick up sev…
42.93% 1000ms 131072K LATTICE is learning Digital Electronic Technology. He is talented, so he understood all those pieces of knowledge in 10^{-9}10−9 second. In the next 10^{-9}10−9 second, he built a data decoding device that decodes data encoded w…
26.89% 1000ms 131072K A prime number (or a prime) is a natural number greater than 11 that cannot be formed by multiplying two smaller natural numbers. Now lets define a number NN as the supreme number if and only if each number made up of an non-emp…
Lattice's basics in digital electronics 44.08% 1000ms 131072K   LATTICE is learning Digital Electronic Technology. He is talented, so he understood all those pieces of knowledge in 10^{-9}10−9 second. In the next 10^{-9}10−9 second, he built a data d…
query \[ Time Limit: 2000 ms \quad Memory Limit: 262144 kB \] 题意 补题才发现比赛的时候读了一个假题意.... 给出长度为 \(n\) 的排列,在给出 \(m\) 次询问,每次询问有一对 \(l.r\),问满足 \(min(ai, aj) = gcd(ai, aj)\) 的 \(pair(i, j)\) 对数. 思路 考虑离线做 先把每个数出现的位置记录下来,然后预处理出所有的 \(pair\). 对于一个数字 \(x\),其满足条件…
Robots \[ Time Limit: 1000 ms \quad Memory Limit: 262144 kB \] 题意 有一个机器人要从 \(1\) 点走到 \(n\) 点,每走一步都需要一天,并且这一步的代价是已经经过的天数. 思路 将问题拆成两个问题,\(dp1[i]\) 表示从 \(i\) 到 \(n\) 的天数期望,\(dp2[i]\) 表示从 \(i\) 到 \(n\) 的代价期望. 那么就很容易得到 \[ dp1[u] = \frac{\sum_{u->v}(dp1[v]…
题目链接 2019.9.2更新 第二天睡醒想了想发现好像搜一遍就可以过,赛时写的花里胡哨的还错了,太菜了QAQ #include<bits/stdc++.h> using namespace std; typedef long long ll; ; struct node { int s, e, next; }edge[maxn]; int head[maxn], len; void init() { memset(head, -, sizeof(head)); len = ; } void…
Traversal Best Solver Minimum Cut Dividing This Product Excited Database Fang Fang Matches Puzzle Game Hold Your Hand Stability Jesus Is Here Poker Largest Point Manors…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5900 Problem Description Every school has some legends, Northeastern University is the same. Enter from the north gate of Northeastern University,You are facing the main building of Northeastern Universi…