Educational Codeforces Round 112 ABCDE 题解 (Java/C++)

A. PizzaForces

题解

不难发现平均每一片都需要2.5分钟。同时,我们发现超过6的所有偶数都能构造出来。于是,对于偶数,我们直接乘以2.5即可;对于奇数,加一后再乘以2.5即可。

代码

Java

Submission #124470201 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #124470234 - Codeforces
Codeforces. Programming competitions and contests, programming community

B. Two Tables

题解

显然,绿色的桌子一定会放在四个角,枚举四个角即可。

代码

Java

Submission #124471079 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #124471166 - Codeforces
Codeforces. Programming competitions and contests, programming community

C. Coin Rows

题解

我们可以发现,对于Bob来说,要么全走上边(蓝色),要么全走下边(绿色)。否则对于Bob来说一定不是最优解。因此只需要枚举Alice转弯的位置即可,然后通过前缀和快速算出Bob的得分即可。

代码

Java

Submission #124480588 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #124480695 - Codeforces
Codeforces. Programming competitions and contests, programming community

D. Say No to Palindromes

题解

不难发现,其子串一定是abc三个字母的某种排列的重复,这样才能保证所有子串不是回文串。比如bacbacbac...

于是我们对6种排列都预先计算好需要修改的操作数的前缀和。对于每个查询,我们遍历6种可能,然后根据前缀和求出需要改变的字符总数即可。

代码

Java

Submission #124482859 - Codeforces
Codeforces. Programming competitions and contests, programming community

C++

Submission #124483134 - Codeforces
Codeforces. Programming competitions and contests, programming community

E. Boring Segments

这个题的关键点在于,结果只取决于w的最大值和最小值。因此考虑按w排序后,选取一个最小的区间,使得恰好能够完成1-m的通路即可。

Educational Codeforces Round 112 Boring Segments 题解 (Java/C++)
题解首先,我们注意到最终结果只和w的最大值和最小值有关。这将意味着,只要w在最大值和最小值之间,这个线段加不加进来其实都不会影响。
点击上面链接查看详细题解
蜀ICP备19018968号