@@ -3463,7 +3463,7 @@ $$<div class="highlight"><div class="chroma">
34633463<p>处理如下 $Q$ 次询问:</p>
34643464<ul>
34653465<li><code>1 x</code>:将数字 $x$ 追加至 $S$ 的最后面。保证 $x \in \{1,2,3,4,5,6,7,8,9\}$。</li>
3466- <li><code>2</code>:删除 $S$ 的第一个字符。保证此时 $|S|>1$。</li>
3466+ <li><code>2</code>:删除 $S$ 的第一个字符。保证此时 $|S| > 1$。</li>
34673467<li><code>3</code>:输出 $S$ 在十进制中对应的数字,对 $998244353$ 取模。</li>
34683468</ul>
34693469<p>$1\le Q\le 6\times 10^5$</p>
@@ -3789,7 +3789,7 @@ $(r_i,c_i)\ne (r_j,c_j)~~~~~~(i\ne j)$</p>
37893789<p>容易发现,$f(R,C)=\mathrm{rs}_R+\mathrm{cs}_C-A_{R,C}$。</p>
37903790<p>然后证明当 $f(R,C)$ 最大时,$\mathrm{rs}_R,\mathrm{cs}_C\ne0$:</p>
37913791<ul>
3792- <li>若 $\mathrm{rs}_R=\mathrm{cs}_C=0$,则 $f(r_0,c_0)=x_0>0=f(R,C)$,所以 $(R,C)$ 不是最优解;</li>
3792+ <li>若 $\mathrm{rs}_R=\mathrm{cs}_C=0$,则 $f(r_0,c_0)=x_0 > 0=f(R,C)$,所以 $(R,C)$ 不是最优解;</li>
37933793<li>若 $\mathrm{rs}_R\ne0,\mathrm{cs}_C=0$,则 $f(R,c_0)=\mathrm{rs}_R+\mathrm{cs}_{c_0}-A_{R,c_0}\ge f(R,C)=\mathrm{rs}_R$,所以 $(R,C)$ 不是最优解(或有多个最优解,但其中至少有一个解 $(x,y)$ 使得 $\mathrm{rs}_x,\mathrm{cs}_y\ne0$)</li>
37943794<li>$\mathrm{rs}_R=0,\mathrm{cs}_C\ne0$ 同理。</li>
37953795</ul>
@@ -5887,7 +5887,7 @@ $1\le A_i\le 2i-1$</p>
58875887</h2><p>给定整数$N$和序列$A=(A_1,A_2,\dots,A_N)$,能否在平面直角坐标系中通过$N$步从$(0,0)$走到$(x,y)$?每一步如下:</p>
58885888<ul>
58895889<li>第$1$步:从$(0,0)$走到$(A_1,0)$(向右前进$A_1$格)。</li>
5890- <li>第$i$步($i>1$)先左转或右转$90\degree$,再前进$A_i$格。</li>
5890+ <li>第$i$步($i > 1$)先左转或右转$90\degree$,再前进$A_i$格。</li>
58915891</ul>
58925892<p>$2\le N\le 10^3$<br>
58935893$1\le A_i\le 10$<br>
@@ -6761,7 +6761,7 @@ P.S. 这函数,不知是哪位神仙想出来的……</p>
67616761</div><p>这样可保证每次枚举到的都是大小为$K$的子集,可以大大提高算法效率。</p>
67626762<h4 id="扩展stdbitset">扩展:std::bitset
67636763</h4><p><code>bitset</code>,顾名思义,即为用位运算操作的集合。<br>
6764- 对于元素个数$N\in [1,64]$,集合$\{0,1,\dots,N-1\}$的任意子集都可以用一个$32$或$64$位整数表示出来,操作时间复杂度为$\mathcal O(1)$。那么对于$N>64$,怎么办?我们可以用多个$32$或$64$位无符号整数拼凑为一个$N$位的<code>bitset</code>,容易发现其操作的时间复杂度为$\mathcal O(\frac Nw)$($N$位的二进制数可用$\lceil\frac Nw\rceil$个$w$位无符号整数拼凑而成),其中$w$一般为$32$或$64$。</p>
6764+ 对于元素个数$N\in [1,64]$,集合$\{0,1,\dots,N-1\}$的任意子集都可以用一个$32$或$64$位整数表示出来,操作时间复杂度为$\mathcal O(1)$。那么对于$N > 64$,怎么办?我们可以用多个$32$或$64$位无符号整数拼凑为一个$N$位的<code>bitset</code>,容易发现其操作的时间复杂度为$\mathcal O(\frac Nw)$($N$位的二进制数可用$\lceil\frac Nw\rceil$个$w$位无符号整数拼凑而成),其中$w$一般为$32$或$64$。</p>
67656765<p>C++的<code>Standard Template Library</code>(<code>STL</code>)为我们提供了<code>&lt;bitset&gt;</code>头文件,用于<code>bitset</code>的定义。</p>
67666766<p>用法如下:</p>
67676767<table>
@@ -14735,7 +14735,7 @@ $A_M~B_M~C_M$</p>
1473514735</blockquote>
1473614736<p>有一个的整数序列$S$,初始只有一个元素$L$,我们可以执行如下操作无限次:</p>
1473714737<ul>
14738- <li>从$S$中删去任意元素$k$($k>1$),同时选取整数$x$($1\le x\le k-1$),将$x$和$k-x$放入$S$。<strong>此操作的代价为$k$。</strong></li>
14738+ <li>从$S$中删去任意元素$k$($k > 1$),同时选取整数$x$($1\le x\le k-1$),将$x$和$k-x$放入$S$。<strong>此操作的代价为$k$。</strong></li>
1473914739</ul>
1474014740<p>求最小的代价,使得$A$在$S$中,<strong>即$A$中每个元素的出现次数$~\le S$中对应元素的出现次数</strong>。</p>
1474114741<p>$2\le N\le 2\times 10^5$<br>
@@ -20673,7 +20673,7 @@ $0\le K\le N$</p>
2067320673 data-flex-basis="268px"
2067420674
2067520675></p>
20676- <p>由此可见,如果$N>M+K$(即终点超出限制),答案一定为$0$。<br>
20676+ <p>由此可见,如果$N > M+K$(即终点超出限制),答案一定为$0$。<br>
2067720677我们还可以发现,如果没有$y\le x+K$这个限制,答案为$\binom{N + M}{N}$。<br>
2067820678我们再考虑不合法的路径数,数量为$\binom{N + M}{M + K + 1}$。<br>
2067920679因此,答案为$\binom{N + M}{N}-\binom{N + M}{M + K + 1}$。</p>
@@ -26118,7 +26118,7 @@ $1\le W\le 1000$</p>
2611826118<h2 id="分析-1">分析
2611926119</h2><p>如果要得到最小的结果,那么每个橙子的单价必定要取最大值。所以,我们设$min=\lceil\frac WB\rceil$。<br>
2612026120同理,如果要得到最大的结果,那么每个橙子的单价必定要取最小值。所以,我们设$max=\lfloor\frac WA\rfloor$。<br>
26121- 计算完成后,如果$min>max$,说明数据不合法;否则,输出$min$和$max$。</p>
26121+ 计算完成后,如果$min > max$,说明数据不合法;否则,输出$min$和$max$。</p>
2612226122<h2 id="代码-1">代码
2612326123</h2><div class="highlight"><div class="chroma">
2612426124<table class="lntable"><tr><td class="lntd">
@@ -27128,7 +27128,7 @@ $A_N~P_N~X_N$</p>
2712827128</span></span></code></pre></td></tr></table>
2712927129</div>
2713027130</div><h2 id="分析-1">分析
27131- </h2><p>对于第$i$个商店,如果$X_i>A_i$,则Takahashi到达时商品没有卖光,这时取最大的$P_i$输出即可。如果没有$i$符合条件$X_i>A_i$,则输出<code>-1</code>。</p>
27131+ </h2><p>对于第$i$个商店,如果$X_i > A_i$,则Takahashi到达时商品没有卖光,这时取最大的$P_i$输出即可。如果没有$i$符合条件$X_i > A_i$,则输出<code>-1</code>。</p>
2713227132<h2 id="代码-1">代码
2713327133</h2><div class="highlight"><div class="chroma">
2713427134<table class="lntable"><tr><td class="lntd">
@@ -28447,7 +28447,7 @@ $C \in \{0,1\}$</p>
2844728447 </tbody>
2844828448</table>
2844928449<h2 id="分析">分析
28450- </h2><p>可以看出,如果是Aoki先吃($C=1$),那么当$B>A$时,Aoki会赢。那么如果Takahashi先吃($C=1$),我们可以先将$B$加上$1$,这时就变成了前一种情况,再判断$B>A$是否成立即可。</p>
28450+ </h2><p>可以看出,如果是Aoki先吃($C=1$),那么当$B > A$时,Aoki会赢。那么如果Takahashi先吃($C=1$),我们可以先将$B$加上$1$,这时就变成了前一种情况,再判断$B > A$是否成立即可。</p>
2845128451<h2 id="代码">代码
2845228452</h2><div class="highlight"><div class="chroma">
2845328453<table class="lntable"><tr><td class="lntd">
@@ -34400,7 +34400,7 @@ $4ab < (c - a - b)^2$<br>
3440034400 >A. Cow and Haybales</a>
3440134401</h1><h2 id="题面">题面
3440234402</h2><p>The USA Construction Operation (USACO) recently ordered Farmer John to arrange a row of n haybale piles on the farm. The $i$-th pile contains $a_i$ haybales.</p>
34403- <p>However, Farmer John has just left for vacation, leaving Bessie all on her own. Every day, Bessie the naughty cow can choose to move one haybale in any pile to an adjacent pile. Formally, in one day she can choose any two indices $i$ and $j$ ($1\le i,j\le n$) such that $|i−j|=1$ and $a_i>0$ and apply $a_i=a_i−1$, $a_j = a_j + 1$. She may also decide to not do anything on some days because she is lazy.</p>
34403+ <p>However, Farmer John has just left for vacation, leaving Bessie all on her own. Every day, Bessie the naughty cow can choose to move one haybale in any pile to an adjacent pile. Formally, in one day she can choose any two indices $i$ and $j$ ($1\le i,j\le n$) such that $|i−j|=1$ and $a_i > 0$ and apply $a_i=a_i−1$, $a_j = a_j + 1$. She may also decide to not do anything on some days because she is lazy.</p>
3440434404<p>Bessie wants to maximize the number of haybales in pile $1$ (i.e. to maximize $a_1$), and she only has $d$ days to do so before Farmer John returns. Help her find the maximum number of haybales that may be in pile $1$ if she acts optimally!</p>
3440534405<h2 id="输入">输入
3440634406</h2><p>The input consists of multiple test cases. The first line contains an integer $t$ ($1\le t\le 100$) — the number of test cases. Next $2t$ lines contain a description of test cases — two lines per test case.</p>
0 commit comments