Isosceles Right Triangles 坐标暴力枚举

Isosceles Right Triangles

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 126    Accepted Submission(s): 74

Problem Description
Apple is a very careless girl. One day, the teacher leaves her a problem which has stuck her for a long while. Apple turns to you with this problem: counting the number of the isosceles right triangles composed with various letters in a capital letters matrix. And there are only two forms of the isosceles right triangle in the matrix:
Form 1:
Two right sides are both parallel with the sides of the matrix. e.g.
Form 2:
The hypotenuse is parallel with one side of the matrix. e.g.


Notice that all the isosceles right triangles should contain more than or equal to three letters.

Input
The first line of the input file contains a single integer t ( 1 ≤ t ≤ 20 ), the number of test cases, followed by the input data for each test case. The first line of each test case consists of one integer K ( 1 ≤ K ≤ 50). K is the size of matrix. The follow K lines, each lines has K capital letters, describe a K*K character matrix. There is no space both at the beginning and the end of all the lines.
 
Output
For each collection, output "Case k:", where k is the number of the test case. To every letter appeared in the matrix, it is required to count the number of the isosceles and right triangles in the matrix composed with it. Moreover, the output should be arrayed in the nature order of these letters in a dictionary. A blank should be left between the letter and its corresponding number. We confirm that the result are less than 2^31.
 
Sample Input
  
  
2 3 AAB ABB BBC 4 AABB ABBB BBBB BBBB

Sample Output
  
  
Case 1: A 1 B 3 C 0 Case 2: A 1 B 50

直接暴力枚举顶点,判断八个方向。需要注意的是题目给你的2种不同三角形的情况

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值