22319_WrongAnswer

2022-5-16 18:21| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506317956899-Problem List-采集的数据-后羿采集器.html

Pro.ID

22319

Title

Wrong Answer

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22319

AC

3

Submit

18

Ratio

16.67%

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    You are solving a crossword puzzle and you have already written down the answers to all questions. While filling in the answers in the diagram, you notice that some answers have overlapping letters that do not match, so you must have made some mistakes in the answers. Instead of checking your answers, you decide to write a computer program to find the maximum number of answers that could have been correct.

    输入

    The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format:

    • One line with two integers H and V , satisfying 1 ≤ H, V ≤ 500: the number of horizontal and vertical words, respectively.

    • H lines, one for each horizontal word, each with two integers x and y and a string W, satisfying 0 ≤ x, y ≤ 1,000 and 1 ≤ Length(W) ≤ 1,000: the location of the first letter and the answer.

    • V lines, one for each vertical word, each with two integers x and y and a string W, satisfying 0 ≤ x, y ≤ 1,000 and 1 ≤ Length(W) ≤ 1,000: the location of the first letter and the answer.

    Integers and strings on the same line are separated by single spaces. No pair of horizontal words will overlap, nor will any pair of vertical words. The words consist of upper case letters only.

    The top left corner of the diagram is at x = y = 0, x runs in the horizontal direction, and y runs in the vertical direction (downwards).

    输出

    Description

    You are solving a crossword puzzle and you have already written down the answers to all questions. While filling in the answers in the diagram, you notice that some answers have overlapping letters that do not match, so you must have made some mistakes in the answers. Instead of checking your answers, you decide to write a computer program to find the maximum number of answers that could have been correct.

    Input

    The first line of the input contains a single number: the number of test cases to follow. Each test case has the following format:

    • One line with two integers H and V , satisfying 1 ≤ H, V ≤ 500: the number of horizontal and vertical words, respectively.

    • H lines, one for each horizontal word, each with two integers x and y and a string W, satisfying 0 ≤ x, y ≤ 1,000 and 1 ≤ Length(W) ≤ 1,000: the location of the first letter and the answer.

    • V lines, one for each vertical word, each with two integers x and y and a string W, satisfying 0 ≤ x, y ≤ 1,000 and 1 ≤ Length(W) ≤ 1,000: the location of the first letter and the answer.

    Integers and strings on the same line are separated by single spaces. No pair of horizontal words will overlap, nor will any pair of vertical words. The words consist of upper case letters only.

    The top left corner of the diagram is at x = y = 0, x runs in the horizontal direction, and y runs in the vertical direction (downwards).

    Output

    For every test case in the input, the output should contain a single number, on a single line: the maximum number of answers that can fit in the crossword.

    Sample Input

    2
    2 2
    0 1 BAPC
    0 2 LEIDEN
    0 0 SOLUTION
    2 1 WINNER
    1 4
    0 1 HELLO
    1 0 HI
    2 0 BYE
    3 0 GOODBYE
    4 0 FAREWELL

    Sample Output

    3
    4

    Hint

    The first example below corresponds to the following diagram, where the (assumed) wrong answer is written in italics:

    Source

    样例输入

    2
    2 2
    0 1 BAPC
    0 2 LEIDEN
    0 0 SOLUTION
    2 1 WINNER
    1 4
    0 1 HELLO
    1 0 HI
    2 0 BYE
    3 0 GOODBYE
    4 0 FAREWELL

    样例输出

    3
    4

    提示

    The first example below corresponds to the following diagram, where the (assumed) wrong answer is written in italics:

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部