POJ 1676 模拟 注意行列! What time is it?

该问题描述了有两个出现故障的LCD屏幕显示时间,其中一个慢15分钟。给定两个模糊的四位数时间,需要确定准确时间。输入包含正确时间和慢15分钟时间的模糊显示,输出能确定的准确时间或'Not Sure'。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

An accutron shows time with four digits, from 0000 to 2359. Every digit is represented by 3*3 characters, including '|'s, '_'s and blanks. When the LCD screen works well, the digits look like the following:

 _     _  _     _  _  _  _  _ 

| |  | _| _||_||_ |_   ||_||_|

|_|  ||_  _|  | _||_|  ||_| _|



There are two accutrons at hand. One shows the accurate time, and the other is 15 minutes late. For example, at 8:25am, the first accutron shows '0825', while the second shows '0810'.

Unfortunately, there is something wrong with the two LCD screens, namely some parts of the digits missed. Your task is to decide the accurate time, according to the fragmental digits showed on the two accutrons.

Input

The first line of the input is a single integer t (1 <= t <= 20), the number of test cases. Each case contains three lines, indicating the time on the accurate accutron and the time on the slow accutron, separated by a blank column. (Please refer to the Sample Input.)

Output

For each input, print the accurate time with four digits if it can be ensured, or otherwise the string 'Not Sure'.

Sample Input

2
    _  _  _      _     _ 
  | _  _||       _   ||  
  | _ |_   |   | _    |_|
    _  _  _   _  _     _ 
  ||_  _||       _|  ||  
  | _ |_   |   ||     |_|

Sample Output

Not Sure
0825

 

// 暴力模拟
#include<stdio.h>
#include<string.h> 
#include<iostream>
//const int ddd = 1; 
const int ddd = 0; 
int d1[10];
int d2[10];
char a[10][50];
int ans;
int ansh,ansm;
const char s[][50] = {
" _     _  _     _  _  _  _  _ ",
"| |  | _| _||_||_ |_   ||_||_|",
"|_|  ||_  _|  | _||_|  ||_| _|"
};
void init(){
	memset(d1,0,sizeof(d1));
	memset(d2,0,sizeof(d2));
	memset(a,0,sizeof(a));
	ans = 0;
}
void showd(){
	printf("D1: ");
	for(int i = 0;i<4;i++){
		printf("%d",d1[i]);
	}
	printf("\nD2: ");
	for(int i = 0;i<4;i++){
		printf("%d",d2[i]);
	}
	printf("\n");
}
void gend(int h1,int m1,int h2,int m2){
//	if(ddd){
//		printf("gend : %d %d -> %d %d\n",h1,m1,h2,m2); 
//	}
	d1[0] = h1/10;
	d1[1] = h1%10;
	d2[0] = h2/10;
	d2[1] = h2%10;
	d1[2] = m1/10;
	d1[3] = m1%10;
	d2[2] = m2/10;
	d2[3] = m2%10;
//	if(ddd)showd();
}
bool cmpd(int b,int ii){
	// a b b+3
	// s d1[0] d1[1]
	for(int i = 0;i<4;i++){
		int d = ii==1?d1[i]:d2[i];
		if(ddd)printf("d%d = %d\n",ii,d);
		for(int j = 0;j<3;j++){
			int ida = b+i*3+j;
			int idd = d*3+j; 
			for(int k = 0;k<3;k++){
				if(a[k][ida] == s[k][idd])continue;
				if(a[k][ida] != ' '&&s[k][idd]!=a[k][ida])return false;
			} 
		}
	}
	return true;
}
void shows(){
	for(int i = 0;i<3;i++){
		for(int j = 0;j<26;j++){
			printf("%c",a[i][j]);
		}
		printf("\n");
	} 
}
int main(){
	int nn;
	scanf("%d",&nn);
	getchar(); 
	while(nn--){
		init(); 
		for(int i = 0;i<3;i++){
			gets(a[i]);
		} 
		if(ddd)shows(); 
		// 
		int h = 0,m = 0;
		for(int h = 0;h<24;h++){
			for(int m = 0;m<60;m++){
				// 计算推迟15分钟的时间
				int h2 = h;
				int m2 = m-15;
				if(m2<0){
					h2--;
					m2 += 60;
				} 
				if(h2<0){
					h2+= 24;
				} 
				gend(h,m,h2,m2);
//				if(ddd)showd();
				// d1 0825 d2 0810
				// c1 c2
				bool r1 = cmpd(0,1)&&cmpd(13,2);
//				bool r2 = cmpd(13,1)&&cmpd(0,2);
				bool r2 = false;
				if(r1||r2){
					ans++;
					ansh = h;
					ansm = m;
					if(ans == 2){
						if(ddd)showd();
						break;
					}
				} 
				if(ans == 2)break;
			}
			if(ans == 2)break;
		} 
		if(ans ==1){
			printf("%02d%02d\n",ansh,ansm);
		}
		else{
			printf("Not Sure\n");
		} 
	}
} 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值