QOJ.ac

QOJ

Límite de tiempo: 3 s Límite de memoria: 512 MB Puntuación total: 100

#1836. 荣耀图

Estadísticas

给定一个包含 $n$ 个顶点的完全无向图,每条边都被染成蓝色或黄色。如果一个 4 顶点子图的 6 条边中,有 5 条边颜色相同,而第 6 条边颜色不同,则 Anton 喜欢该子图。如果一个 4 顶点子图的 6 条边中有 3 条黄色边和 3 条蓝色边,且不存在 3 个顶点构成的同色三角形,则 Yahor 喜欢该子图。

在下图中,左侧展示了 Anton 喜欢的图的示例,右侧展示了 Yahor 喜欢的图的示例。

设 $A$ 为 Anton 喜欢的子图数量,$Y$ 为 Yahor 喜欢的子图数量。他们想知道谁喜欢的子图更多。请计算 $Y - A$ 的值。

输入格式

输入的第一行包含一个整数 $n$ ($4 \le n \le 2000$),表示图中的顶点数。 接下来的 $n$ 行,第 $i$ 行包含一个长度为 $n$ 的字符串 $s_i$。

保证: 对于每个 $1 \le i \le n$,$s_i$ 的第 $i$ 个字符为 '-'。 对于每个 $i \neq j$,$s_i$ 的第 $j$ 个字符为 'Y' 或 'B',其中 'Y' 表示顶点 $i$ 和 $j$ 之间的边为黄色,'B' 表示为蓝色。 * 对于每个 $i \neq j$,$s_i$ 的第 $j$ 个字符等于 $s_j$ 的第 $i$ 个字符。

输出格式

输出一个整数:$Y - A$ 的值。

样例

输入格式 1

5
-YBYB
Y-BBB
BB-BY
YBB-Y
BBYY-

输出格式 1

2

说明

在第一个样例中,Yahor 喜欢顶点 $\{1, 2, 4, 5\}$ 和 $\{1, 3, 4, 5\}$ 构成的子图。Anton 在该图中不喜欢任何子图。

输入格式 2

6
-YYYYY
Y-YYBB
YY-YYY
YYY-YB
YBYY-Y
YBYBY-

输出格式 2

-6

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.