题目:

              Faulty dial

Pavel has not played ACM for ages, nor does he train teams, nor prepare problems. The thing is that there are much more global issues that concern him — Pavel ponders on education as a whole. His thoughts are always busy with this, but the problem is that various insignificancies distract him all the time! Let us look at a microwave oven, for example. Firstly, it does not allow to set exact time in seconds for warming up food, whilst seconds play the key role in this issue! That is why Pavel has to set the minimal available time option exceeding the time needed, and to keep an eye on the timer in order to switch the oven off at the right moment. Secondly, as it came out, the oven’s dial is faulty — random digit segments may be not displayed when indicating time. As a result it becomes nearly impossible to stop the oven at the correct moment of time — with faulty dial Pavel is unable to read what the timer is displaying at each moment.
Help Pavel — write a program recovering real timer data.

Input

The first line contains n (1 ≤ n ≤ 100) — the number of timer readings recorded by Pavel. Next lines represent n timer readings. Each reading is described with 3 lines 17 characters of length each, and encodes a timer value in MM:SS format (minutes and seconds).
Each timer digit is encoded in 9 characters: three characters in each of 3 strings. Higher order digit for minutes is encoded with characters in the positions 1−3 (here and further positions are enumerated starting with 1), lower order digit for minutes — with characters 5−7, higher order digit for seconds — with characters in the positions 11−13, lower order digit for seconds — with characters 15−17. Characters ’_’ (underscore, decimal ASCII code 95), ’|’ (vertical bar, decimal ASCII code 124) and ’.’ (full stop, decimal ASCII code 46) are used to encode digits. Code descriptions for all nine digits (with all segments displayed) are listed below.
._. ... ._. ._. ... ._. ._. ._. ._. ._.
|.| ..| ._| ._| |_| |_. |_. ..| |_| |_|
|_| ..| |_. ._| ..| ._| |_| ..| |_| ._|
Character ’*’ (asterisk, decimal ASCII code 42) stands in the ninth position at the timer’s readings lines 2 and 3,and all positions not mentioned above contain full stops.
If a segment of a digit is not displayed at the dial, this character will be replaced with a full stop in its encoded representation (segments encoded with full stop are always displayed correctly).

Output

Output n MM:SS formatted lines representing the recovered sequence of timer’s values. Line i must correspond with the i-th reading and has to be a valid time value between 00:00 and 59:59. Each subsequent value must be strictly less than the preceding one. If several answers exist, output any of them. It is guaranteed that there is at least one consistent sequence.

Example

input output
2
._..._........._.
|...._|.*...|.._|
|_|.._..*...|.|..
....._....._..._.
|.|...|.*.|.|.._.
|.|.|_..*.|_|.._.
03:12
00:05

思路:按时间从大到小搜就好了,代码还是挺短的,不过还是感觉被恶心到了。

 #include <bits/stdc++.h>

 using namespace std;

 #define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int,int> PII;
const double eps=1e-;
const double pi=acos(-1.0);
const int K=1e6+;
const int mod=1e9+; int ch[];
char ss[][];
char num[][]=
{ " ",
" ._....._.._....._.._.._.._.._.",
" |.|..|._|._||_||_.|_...||_||_|",
" |_|..||_.._|..|._||_|..||_|._|"
};
bool sc(int sk,int x,int y)
{
for(int i=;i<;i++)
for(int j=;j<;j++)
{
if(!(ss[sk+i][x+j]=='.'||ss[sk+i][x+j]==num[i+][y+j]))
return ;
}
return ;
} int main(void)
{
for(int i=;i<;i++)
ch[i]=i*+;
int t,ln=;cin>>t;
gets(ss[]);
for(int i=;i<=*t;i++)
gets(&ss[i][]);
for(int i=;i>=;i--)
for(int j=;j>=;j--)
for(int k=;k>=;k--)
for(int p=;p>=;p--)
if(sc(+ln*,,ch[i])&&sc(+ln*,,ch[j])&&sc(+ln*,,ch[k])&&sc(+ln*,,ch[p]))
{
printf("%d%d:%d%d\n",i,j,k,p);
if(++ln>=t)
return ;
}
while();
}

URAL 2081 Faulty dial的更多相关文章

  1. 【枚举】URAL - 2081 - Faulty dial

    //._. ... ._. ._. ... ._. ._. ._. ._. ._. //|.| ..| ._| ._| |_| |_. |_. ..| |_| |_| //|_| ..| |_. ._ ...

  2. URAL 2078~2089

    URAL 2078~2089 A - Bowling game 题目描述:给出保龄球每一局击倒的球数,按照保龄球的规则,算出总得分的最小值和最大值. solution 首先是最小值:每一局第一球击倒\ ...

  3. 如何为Surface Dial设备开发自定义交互功能

    随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来 ...

  4. BZOJ 2081: [Poi2010]Beads

    Description 问把n截成每个长度后不同子串个数. Sol 调和极数+Hash. 首先这是一个式子 \(n\sum_{i=1}^n \frac {1}{i}\) . 这东西就是调和极数再乘上 ...

  5. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  6. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  7. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  8. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  9. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

随机推荐

  1. jQuery实现浮动层跟随页面滚动效果

      helloweba.com Author:月光光 Time:2010-11-29 09:02 Tag: jquery  滚动 在本文中,我将介绍一个可以跟随页面滚动的层效果,当用户滚动鼠标滚轮或者 ...

  2. 技巧C#

    1.     在CallBack之后保持滚动条的位置: 在Asp.Net1.1中,CallBack之后保持滚动条的位置是一件非常痛苦的事情,特别是页中有一个Grid并且想要编辑特定的行.为了不停留在想 ...

  3. BootStrap带样式打印

    在新窗口打印时bootstrap表格的样式出不来,因为打印时没有加载CSS样式. 我在jquery.PrintArea.js的基础上改造了下打印的方法: (function ($) { var pri ...

  4. redis Could not connect to Redis at 127.0.0.1:6379: Connection refused 问题解决

    1.启动redis 客户端 redis-cli 报错 redis Could not connect to Redis at 127.0.0.1:6379: Connection refused 是因 ...

  5. 解决 UIView 设置背景为UIImage图片变型问题[XXX setBackgroundColor:[UIColor colorWithPatternImage:XXX]];

    [self.drawingViewsetBackgroundColor:[UIColorcolorWithPatternImage:[selfthumbnailWithImageWithoutScal ...

  6. Android 4.4 (KitKat) SMS Apis Change——Android 4.4的一个重大变化

    Android团队通过Android开发博客透漏今年会放出Android 4.4 (KitKat) ,同时更新了 SMS 的部分API.博客上讲只有default SMS app才能对短信数据库有写权 ...

  7. 同时调整lv分区的大小(减少一个,增加另一个)

    author:headsen chen date: 2018-04-20  16:48:06 1.查看分区:/home 为67G,太大了,/ 是50g,太小了. [root@localhost ~]# ...

  8. 【BZOJ4456】[Zjoi2016]旅行者 分治+最短路

    [BZOJ4456][Zjoi2016]旅行者 Description 小Y来到了一个新的城市旅行.她发现了这个城市的布局是网格状的,也就是有n条从东到西的道路和m条从南到北的道路,这些道路两两相交形 ...

  9. CURLOPT_SSL_VERIFYPEER CURLOPT_SSL_VERIFYHOST

    w /** * Set curl options relating to SSL. Protected to allow overriding. * @param $ch curl handle */ ...

  10. 综合: Java 对象初始化过程

    class Fu { Fu() { show(); } void show() { System.out.println("xixi"); } } class Zi extends ...