C# - 2017微软校园招聘笔试题 之 MS Recognition[待解决]
MS Recognition
在线提交:
hihoCoder 1402 http://hihocoder.com/problemset/problem/1402
类似:
OpenJudge - I:PKU Zealots http://poj.openjudge.cn/campus2016/I/
描述
Given an image containing only two kinds of capital letters, ‘M’ and
‘S’, can you tell how many of each letter are there in the image? Note
that the letters may be of different sizes and may be rotated.
输入
The first line contains two integers H and W, indicating the height
and weight of the image. (1 <= H, W <= 500)Then follows an H x W matrix indicating the image.
‘.’ indicates the pixel is empty and ‘#’ indicates the pixel is part
of a letter.It is guaranteed that:
The letters are actually in Microsoft Yahei font.
Each letter consists of at least 20 pixels.
Different letters are at least 2 pixels away from each other.
输出
Two integers, the number of ‘M’ letters and the number of ‘S’ letters.
样例输入
50 50
………………………………………………
……………………………………………….
……………………………………….#…….
………………………..###……….##…….
…….##………………##.##…….#………
…….##………………#…………##………
……###…….#……….#………..##………
……####…..###………###…….######…
……#.##…..###……….####……………#…
……#.##….####…………##…………..#…
…..##..#…##.#………..#…#…………##…
…..##..#..##.##……..#####……….##…..
…..#…#.##..##……………………………
…..#…###…#…………………………….
…..#…###…#…………………………….
………##…##………………….##……….
…………..##…..##…………..###……….
………………..###…………###…………
……………….###………….##………….
………………###………….##…………..
……………..###…………..##…………..
…………….###……###…….########…….
……………###…..#####……..########……
…………..###…########……………##…..
………….###..#####..##…………….##…..
…………########….###…………….##…..
………..#######……##…..##………###…..
…………###………##….###…….####……
…………………..###…###…….###……..
…….#……………##…###……………….
…..####………….###..###………………..
…######………….##..###…………………
..####…………….######………………….
..###…………….######…………………..
.###……………..#####…….##……………
.###…………….#####……..######………..
.###……………..###………##########…….
..##########…………………..##…####……
..############………………….##…………
….###########………………….###……….
………….##…………………..###………
………….###…………………..###……..
………….###……………….#######……..
………….##…………….########………..
…………###…………….####……………
……….####………………######…………
…….######………………….######………
…….###………………………..##………
…………………………………………..
…………………………………………..
输入的图形变形了,下面附上截图:
样例输出
3 4
思路:
参考:
2017微软秋季校园招聘在线编程笔试4——1402 : MS Recognition - 简书
https://www.jianshu.com/p/6957bc1664f1
我来贴一个第四题的思路 - hihoCoder
http://hihocoder.com/discuss/question/3970