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.
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(1≤T≤1440)
, 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.
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:00≤t≤23:59)
, denoting the time shown on the clock.
Sample Input
1 .XX...XX.....XX...XX. X..X....X......X.X..X X..X....X.X....X.X..X ......XX.....XX...XX. X..X.X....X....X.X..X X..X.X.........X.X..X .XX...XX.....XX...XX.
Sample Output
02:38
题意:输入7 X 21的字符串,输出时间
分析:直接模拟啊,0-20列,第4 9 10 11 16 列都不是有效的列,剩下的16列表示4个数,并且都是连续的,每一个7 X 4都判断一次,看看是什么数,输出即可
AC代码如下:
#include <iostream> #include <cstdio> #include <cstring> #include <string> using namespace std; char a[10][25]; char ch[7][4]; int fun(char c[7][4])//利用数形状的差距直接判断 { for(int i=0;i<7;i++) for(int j=0;j<4;j++) { if(c[3][1]=='X' && c[3][2]=='X') { if(c[0][1]=='.' && c[0][2]=='.') return 4; if(c[4][0]=='X' && c[5][0]=='X') { if(c[1][0]=='.' && c[2][0]=='.') return 2; if(c[1][3]=='X' && c[2][3]=='X') return 8; return 6; } else { if(c[1][3]=='.' && c[2][3]=='.') return 5; if(c[1][0]=='.' && c[2][0]=='.') return 3; return 9; } } else if(c[3][1]=='.' && c[3][2]=='.') { if(c[1][0]=='X' && c[2][0]=='X') return 0; if(c[0][1]=='X' && c[0][2]=='X') return 7; return 1; } } return -1; } int main() { int t; cin>>t; getchar(); while(t--) { for(int i=0;i<7;i++) scanf("%s",a[i]); int num=0; int coun=0; for(int j=0;j<21;j++) { if(j==4 || j==9 || j==10 || j==11 || j==16) { continue; } else { num++; } if(num%4==0)//累计四行做一次判断 { for(int i=0;i<7;i++) { for(int k=j-3,s=0;k<=j;k++,s++) { ch[i][s]=a[i][k]; } } cout<<fun(ch); coun++; if(coun==2) cout<<":"; } } cout<<endl; } return 0; }