题目 一眼题. 缩点然后dp. 注意一下计算一条边经过无限次可以获得多少价值这个东西要用到平方和公式. \(\sum\limits_{i=1}^ni^2=\frac{i(i+1)(2i+1)}6\) #include<bits/stdc++.h> #define ll long long #define pb push_back #define pi pair<int,int> using namespace std; int read(){int x;scanf("%d…
E. Ralph and Mushrooms time limit per test 2.5 seconds memory limit per test 512 megabytes input standard input output standard output Ralph is going to collect mushrooms in the Mushroom Forest. There are m directed paths connecting n trees in the Mu…
Ralph is going to collect mushrooms in the Mushroom Forest. There are m directed paths connecting n trees in the Mushroom Forest. On each path grow some mushrooms. When Ralph passes a path, he collects all the mushrooms on the path. The Mushroom Fore…
Code: #include<cstdio> #include<stack> #include<cstring> using namespace std; const int maxn = 1000000 + 3; stack<int>S; int head[maxn], nex[maxn], val[maxn], to[maxn], cnt, n, m, s; int low[maxn], dfn[maxn], vis[maxn], answer[maxn…
BC都被hack的人生,痛苦. 下面是题解的表演时间: A. QAQ "QAQ" is a word to denote an expression of crying. Imagine "Q" as eyes with tears and "A" as a mouth. Now Diamond has given Bort a string consisting of only uppercase English letters of leng…