题目:http://poj.org/problem?id=1676
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 1483 | Accepted: 578 |
Description
_ _ _ _ _ _ _ _ | | | _| _||_||_ |_ ||_||_| |_| ||_ _| | _||_| ||_| _|
Input
Output
Sample Input
2 _ _ _ _ _ | _ _|| _ || | _ |_ | | _ |_| _ _ _ _ _ _ ||_ _|| _| || | _ |_ | || |_|
Sample Output
Not Sure 0825分析:刚开始没有思路,参照了别人的代码。。将那些字符图案转化为二进制存储,3行字符信息变成1行数字信息,然后暴力分析即可,如果有多个或者没有满足条件的预测时间,那么就是Not sure,否则输出时间。具体见下:
/* 对照字符图案,将数字转化成二进制: 0--> 010 101 111 1--> 000 001 001 2--> 010 011 110 3--> 010 011 011 4--> 000 111 001 5--> 010 110 011 6--> 010 110 111 7--> 010 001 001 8--> 010 111 111 9--> 010 111 011 */ #include <iostream> #include <cstdio> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define repf(i, a, b) for(int i = a; i <= b; i++) const int digit[10][9] = { {0, 1, 0, 1, 0, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 1, 0, 0, 1}, {0, 1, 0, 0, 1, 1, 1, 1, 0}, {0, 1, 0, 0, 1, 1, 0, 1, 1}, {0, 0, 0, 1, 1, 1, 0, 0, 1}, {0, 1, 0, 1, 1, 0, 0, 1, 1}, {0, 1, 0, 1, 1, 0, 1, 1, 1}, {0, 1, 0, 0, 0, 1, 0, 0, 1}, {0, 1, 0, 1, 1, 1, 1, 1, 1}, {0, 1, 0, 1, 1, 1, 0, 1, 1} }; int first[5][10]; //一维:第几个数字; 二维:一行的长度 int second[5][10]; char buf[25]; bool judge_first(int h, int m) { int x = h / 10; rep(i, 9) { if(first[0][i] == 1 && digit[x][i] == 0) return false; } x = h % 10; rep(i, 9) { if(first[1][i] == 1 && digit[x][i] == 0) return false; } x = m / 10; rep(i, 9) { if(first[2][i] == 1 && digit[x][i] == 0) return false; } x = m % 10; rep(i, 9) { if(first[3][i] == 1 && digit[x][i] == 0) return false; } return true; } bool judge_second(int h, int m) { int x = h / 10; rep(i, 9) { if(second[0][i] == 1 && digit[x][i] == 0) return false; } x = h % 10; rep(i, 9) { if(second[1][i] == 1 && digit[x][i] == 0) return false; } x = m / 10; rep(i, 9) { if(second[2][i] == 1 && digit[x][i] == 0) return false; } x = m % 10; rep(i, 9) { if(second[3][i] == 1 && digit[x][i] == 0) return false; } return true; } int main() { //freopen("cin.txt","r",stdin); int t; scanf("%d", &t); getchar(); while(t--) { rep(i, 3) { gets(buf); rep(j, 12) { if(buf[j] == '_' || buf[j] == '|') first[j / 3][i * 3 + j % 3] = 1; else first[j / 3][i * 3 + j % 3] = 0; } repf(j, 13, 24) { if(buf[j] == '_' || buf[j] == '|') second[(j - 1) / 3 - 4][i * 3 + (j - 1) % 3] = 1; else second[(j - 1) / 3 - 4][i * 3 + (j - 1) % 3] = 0; } } int h = -1, m = -1,sum=0; rep(i, 24) { rep(j, 60) { if(judge_first(i, j)) { int x = i; int y = j - 15; if(y < 0) { y += 60; x--; if(x < 0) x = 23; } if(judge_second(x, y)) { sum++; h = i; m = j; } } } } if(sum != 1) printf("Not Sure\n"); else printf("%02d%02d\n", h, m);//%02d 前的0不能丢,不足补齐0 } return 0; }