JZOJ.2020.05.23【NOIP提高组】模拟(反思)

啊我太蒻了!

110

T1 WA 70

T2 WA 20

Bovine Genomics

Description
FJ有n头有斑点的牛和n头没有斑点的牛。由于他刚刚学完牛的基因学的课程,他想知道牛有没有斑点是否与牛的基因有关。
FJ花了巨大的代价测出了每个牛的基因,每头牛的基因用一个长度为M的由“A,C,G,T”的串构成。FJ将这些串写成一个表/矩阵,就像图中这样(N=3的例子)
 
FJ仔细的观察这个表,他发现通过观测2,4位置的字符串可以预测牛是否有斑点。
(在这个例子中,假如他看到24位置是GC、AT或者AC就可以断定其有斑点,因为1号有斑点的牛24位置基因为AC,2号为AT,3号为GC,而且没有任何一头无斑点的牛的24位置出现过这三个串)。
FJ认为,1个或者两个位点是不能够区分品种的,必须是刚好3个位点。他想知道能用多少组三个本质不同的位置判断牛的斑点,{1,2,3}和{1,3,2}是本质相同的

Input
The first line of input contains N ( 1 ≤ N ≤ 500 ) and M ( 3 ≤ M ≤ 50 ). The next N lines each contain a string of M characters; these describe the genomes of the spotty cows. The final N lines describe the genomes of the plain cows.

Output
Please count the number of sets of three distinct positions that can explain spottiness. A set of three positions explains spottiness if the spottiness trait can be predicted with perfect accuracy among Farmer John's population of cows by looking at just those three locations in the genome.

Sample Input
3 8
AATCCCAT
GATTGCAA
GGTCGCAA
ACTCCCAG
ACTCGCAT
ACTTCCAT

Where's Bessie?

Description
农夫John正在测试一个他新发明的全自动寻找奶牛无人机,它能够照一张农场的图片然后自动找出奶牛的位置。不幸的是,这个相机并不包含一个优秀的寻找奶牛函数,所以农夫John需要你来写一个。农场的俯瞰图被定义为一个n * n的字符矩阵。矩阵由大写字母A到Z组成,每个字母表示一种可行的颜色。农夫John发现一个可能是奶牛的位置(以下简称PCL)的最好定义如下:一个PCL是一个矩阵(可能是整张图),矩阵的边与图像的边缘平行,且不能被其他PCL所包含(因此PCL内部不可能有PCL)更多的,一个PCL必须满足以下特性:1、矩阵有且只能有2种颜色构成。2、这两种颜色一种构成一个连通块,另一种形成两个或两个以上的连通块。举个例子:AAAAA
ABABA
AAABB
这个矩阵就是一个PCL,其中颜色A构成一个连通块,B构成两个连通块,描述了一只可能以A为底色,B为花纹的奶牛。在这里连通块被定义为:从其中的任何一个点,你能仅通过上下左右移动,到达另外任何一个点(即上下左右相邻)给定农场的照片,请你计算图中有几个PCL。

Input
The first line of input contains N , the size of the grid ( 1 ≤ N ≤ 20 ). The next N lines describe the image, each consisting of N characters.

Output
Print a count of the number of PCLs in the image.

Sample Input
4
ABBC
BBBC
AABB
ABBC

Sample Output
2

Data Constraint

Hint
 In this example, the two PCLs are the rectangles with contents

ABB
BBB
AAB
ABB

and

BC
BC
BB
BC

Modern Art

Description
小TY突然想画画,他有独特的艺术风格,他从N×N空白画布开始,其中0表示画布的空单元格。然后他会在画布上绘制恰好矩形,每个颜色是1到N×N中的一个。他每次可以选择任意一种未使用过的颜色进行绘画。例如,他可以从颜色2的矩形开始,画出这样的画布:

2 2 2 0

2 2 2 0

2 2 2 0

0 0 0 0

然后他可以用颜色7绘制一个矩形:

2 2 2 0

2 7 7 7

2 7 7 7

0 0 0 0

然后他可以在颜色3上绘制一个小矩形:

2 2 3 0

2 7 3 7

2 7 7 7

0 0 0 0

每个矩形都平行于画布边缘,而且矩形可以与整个画布一样大或者像一个单元一样小。每个颜色从1到正好使用一次,后来的颜色可能完全覆盖一些较早画上的颜色。

现在已知画布的最终状态,请计算有多少种颜色可能被第一个被画。

Input
The first line of input contains N , the size of the canvas ( 1 ≤ N ≤ 1000 ). The next N lines describe the final picture of the canvas, each containing N integers that are in the range 0 … N^2 . The input is guaranteed to have been drawn as described above, by painting successive rectangles in different colors.

Output
Please output a count of the number of colors that could have been drawn first.

Sample Input
4
2 2 3 0
2 7 3 7
2 7 7 7
0 0 0 0

Sample Output
14

Data Constraint

Hint
In this example, color 2 could have been the first to be painted. Color 3 clearly had to have been painted after color 7, and color 7 clearly had to have been painted after color 2. Since we don't see the other colors, we deduce that they also could have been painted first.

  

原文地址:https://www.cnblogs.com/HYDcn666/p/GMOJ-B-2020-5-23.html