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:

  1. The letters are actually in Microsoft Yahei font.

  2. Each letter consists of at least 20 pixels.

  3. 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

全部评论

相关推荐

不愿透露姓名的神秘牛友
04-30 11:43
春招失败、父母离婚,好像我的人生一团糟,一年来压力大到常常崩溃。不知道能跟谁聊,朋友其实对我非常好,但是她无意中表达出来的家庭幸福都会刺痛到我……和ai聊天,我的未来在更高处,不在楼下,忍不住爆哭😭
youngfa:害,妹妹,我是一个研究生(很上进很想找到好工作的那种),但去年因为生病回家休养错过了秋招(当时对我的冲击也是非常大的),这学期返校来了也是把论文盲审交了后才开始找工作,现在也是一个offer没有,但我就没有像你一样把这个阶段性的事情绑定到人生上,人生不仅很长,也很广阔,先停下来,放松一下哦。不要被外部环境灌输的思维操控了,好好爱自己!
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务