zoukankan      html  css  js  c++  java
  • 1061. Dating (20)

    Sherlock Holmes received a note with some strange strings: "Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm". It took him only a minute to figure out that those strange strings are actually referring to the coded time "Thursday 14:04" -- since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter 'D', representing the 4th day in a week; the second common character is the 5th capital letter 'E', representing the 14th hour (hence the hours from 0 to 23 in a day are represented by the numbers from 0 to 9 and the capital letters from A to N, respectively); and the English letter shared by the last two strings is 's' at the 4th position, representing the 4th minute. Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.

    Input Specification:

    Each input file contains one test case. Each case gives 4 non-empty strings of no more than 60 characters without white space in 4 lines.

    Output Specification:

    For each test case, print the decoded time in one line, in the format "DAY HH:MM", where "DAY" is a 3-character abbreviation for the days in a week -- that is, "MON" for Monday, "TUE" for Tuesday, "WED" for Wednesday, "THU" for Thursday, "FRI" for Friday, "SAT" for Saturday, and "SUN" for Sunday. It is guaranteed that the result is unique for each case.

    Sample Input:

    3485djDkxh4hhGE 
    2984akDfkkkkggEdsb 
    s&hgsfdk 
    d&Hyscvnm
    

    Sample Output:

    THU 14:04

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    int main(){
    	char a[62],b[62],c[62],d[62];
    	char s[8][4]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
    	scanf("%s%s%s%s",a,b,c,d);
    	int dd;
    	char h;
    	int hh;
    	int m;
    	int i,j;
    	int len=strlen(a);
    	int index1=-1,index2=-1;
    	for(i=0;i<len;i++){
    		if(a[i]==b[i]){
    			if(index1==-1&&(a[i]>='A'&&a[i]<='G')){
    				index1=i;
    			}else if(index1!=-1&&index2==-1&&((a[i]>='A'&&a[i]<='N'||a[i]>='0'&&a[i]<='9'))){
    				index2=i;
    				break;
    			}
    		}
    	}
    	if(a[index1]>='A'&&a[index1]<='G'){
    		dd=a[index1]-'A';
    	}
    	h=b[index2];
    	if(h>='0'&&h<='9'){
    		hh=h-'0';
    	}else if(h>='A'&&h<='N'){
    		hh=h-'A'+10;
    	}
    	len=strlen(c);
    	int index=0;
    	for(i=0;i<len;i++){
    		if(c[i]==d[i]&&(c[i]>='A'&&c[i]<='Z'||c[i]>='a'&&c[i]<='z')){
    			index=i;
    			break;
    		}
    	}
    	printf("%s %02d:%02d
    ",s[dd],hh,index);
    	return 0;
    } 
    

      

  • 相关阅读:
    USACO training course Mother's Milk /// DFS(有点意思) oj10120
    USACO training course Checker Challenge N皇后 /// oj10125
    USACO 2013 January Silver Painting the Fence /// oj23695
    关于priority_queue和sort()对结构体数组的排序
    USACO 2012 March Silver Tractor /// 优先队列BFS oj21567
    NEERC 2015 Adjustment Office /// oj25993
    合并石头(直线+圆圈+强化+优化)
    可持久化树模板
    1047 邮票面值设计 (DFS+DP)
    多线程DP (要一起行动才可以)
  • 原文地址:https://www.cnblogs.com/grglym/p/7821274.html
Copyright © 2011-2022 走看看