HDU 6077 Time To Get Up【】

来源:互联网 发布:js 数组遍历运行不同步 编辑:程序博客网 时间:2024/05/15 21:18

Time To Get Up

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


Problem Description
Little Q's clock is alarming! It's time to get up now! However, after reading the time on the clock, Little Q lies down and starts sleeping again. Well, he has 5 alarms, and it's just the first one, he can continue sleeping for a while.

Little Q's clock uses a standard 7-segment LCD display for all digits, plus two small segments for the '':'', and shows all times in a 24-hour format. The '':'' segments are on at all times.



Your job is to help Little Q read the time shown on his clock.
 

Input
The first line of the input contains an integer T(1T1440), denoting the number of test cases.

In each test case, there is an 7×21 ASCII image of the clock screen.

All digit segments are represented by two characters, and each colon segment is represented by one character. The character ''X'' indicates a segment that is on while ''.'' indicates anything else. See the sample input for details.
 

Output
For each test case, print a single line containing a string t in the format of HH:MM, where t(00:00t23:59), denoting the time shown on the clock.
 

Sample Input
1.XX...XX.....XX...XX.X..X....X......X.X..XX..X....X.X....X.X..X......XX.....XX...XX.X..X.X....X....X.X..XX..X.X.........X.X..X.XX...XX.....XX...XX.
 

Sample Output
02:38

通过观察可以发现每个字符所占的位置的特征是不同的,其中0,1,和7是中间是空的。。。。。


#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<queue>#include<stack>#include<vector>#include<map>#include<set>#include<algorithm>using namespace std;#define ll long long#define ms(a,b)  memset(a,b,sizeof(a))#define maxn 510const int M=1e7+10;const int inf=0x3f3f3f3f;const int mod=1e9+7;const double eps=1e-10;int n,m,k;char s[100][190];int check(int x,int y){    if(s[3][x+1]=='.'&&s[3][x+2]=='.')    {        if(s[0][x+1]=='.')return 1;        if(s[6][x+1]=='.')return 7;        else return 0;    }    else {        if(s[0][x+1]=='.'&&s[6][x+1]=='.')return 4;        if(s[1][x]=='.'&&s[4][x]=='.')return 3;        if(s[1][x]=='.'&&s[4][y]=='.')return 2;        if(s[1][y]=='.'&&s[4][x]=='.')return 5;        if(s[1][y]=='.')return 6;        if(s[4][x]=='.')return 9;       return 8;    }}int main(){  int t;int j;  scanf("%d",&t);  getchar();  while(t--){    for(int i=0;i<7;i++){        for(j=0;j<10;j++)          scanf("%c",&s[i][j]);        char a1,a2;        scanf("%c%c",&a1,&a2);        for(j=10;j<21-2;j++)          scanf("%c",&s[i][j]);        getchar();    }    int a1=check(0,3);    int a2=check(5,8);    int a3=check(10,13);    int a4=check(15,18);    printf("%d%d:%d%d\n",a1,a2,a3,a4);  }  return 0;}


原创粉丝点击