CF1368H1.Breadboard Capacity (easy version)
NOI/NOI+/CTSC
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an easier version of the problem H without modification queries.
Lester and Delbert work at an electronics company. They are currently working on a microchip component serving to connect two independent parts of a large supercomputer.
The component is built on top of a breadboard — a grid-like base for a microchip. The breadboard has n rows and m columns, and each row-column intersection contains a node. Also, on each side of the breadboard there are ports that can be attached to adjacent nodes. Left and right side have n ports each, and top and bottom side have m ports each. Each of the ports is connected on the outside to one of the parts bridged by the breadboard, and is colored red or blue respectively.

Ports can be connected by wires going inside the breadboard. However, there are a few rules to follow:
- Each wire should connect a red port with a blue port, and each port should be connected to at most one wire.
- Each part of the wire should be horizontal or vertical, and turns are only possible at one of the nodes.
- To avoid interference, wires can not have common parts of non-zero length (but may have common nodes). Also, a wire can not cover the same segment of non-zero length twice.
The capacity of the breadboard is the largest number of red-blue wire connections that can be made subject to the rules above. For example, the breadboard above has capacity 7, and one way to make seven connections is pictured below.

Up to this point statements of both versions are identical. Differences follow below.
Given the current breadboard configuration, help Lester and Delbert find its capacity efficiently.
这是问题 H 的一个简化版本,不包含修改查询。
莱斯特和德尔伯特在一家电子公司工作。他们目前正在为一台大型超级计算机研发一款用于连接其两个独立部分的微芯片组件。
该组件构建在一个面包板(breadboard)之上——一种网格状的微芯片基板。面包板具有 n 行和 m 列,每行与每列的交点处均有一个节点。此外,面包板的每一侧都设有可连接至相邻节点的端口:左右两侧各有 n 个端口,上下两侧各有 m 个端口。每个端口在面包板外部连接至被该面包板所桥接的两个部件之一,并分别被染成红色或蓝色。

端口之间可通过布设于面包板内部的导线相互连接。但需遵循以下规则:
- 每根导线必须连接一个红色端口与一个蓝色端口,且每个端口最多只能连接一根导线;
- 导线的每一部分必须为水平或垂直走向,且仅允许在节点处发生转向;
- 为避免信号干扰,导线之间不得存在长度非零的公共部分(但可共享节点);此外,一根导线也不得重复覆盖同一段长度非零的线段。
该面包板的容量定义为在满足上述所有约束条件下所能建立的最大红-蓝端口连接对数。例如,上图所示的面包板容量为 7,下图展示了一种实现七对连接的方式。

至此,本题两个版本(简化版与原版)的题面描述完全一致。差异说明如下。
给定当前面包板的配置,请帮助莱斯特和德尔伯特高效地求出其容量。
输入格式
The first line contains three integers n,m,q (1≤n,m≤105, q=0). n and m are the number of rows and columns of the breadboard respectively. In this version q is always zero, and is only present for consistency with the harder version.
The next four lines describe initial coloring of the ports. Each character in these lines is either R or B, depending on the coloring of the respective port. The first two of these lines contain n characters each, and describe ports on the left and right sides respectively from top to bottom. The last two lines contain m characters each, and describe ports on the top and bottom sides respectively from left to right.
第一行包含三个整数 n,m,q(1≤n,m≤105,q=0)。其中 n 和 m 分别表示面包板的行数与列数。在本版本中,q 恒为 0,仅为了与更难版本保持一致而存在。
接下来四行描述端口的初始着色情况。每行中的每个字符为 R 或 B,分别表示对应端口的颜色。前两行每行包含 n 个字符,分别从上到下描述左侧和右侧的端口;后两行每行包含 m 个字符,分别从左到右描述顶部和底部的端口。
输出格式
Print a single integer — the given breadboard capacity.
输出一个整数——给定的面包板容量。
输入输出样例
输入#1
4 5 0 BBRR RBBR BBBBB RRRRR
输出#1
7
输入解题思路,AI测评打分。不知道怎么写?