{"id":528,"date":"2013-09-05T17:16:20","date_gmt":"2013-09-05T09:16:20","guid":{"rendered":"http:\/\/blog.dayandcarrot.net\/?p=528"},"modified":"2013-09-05T17:16:20","modified_gmt":"2013-09-05T09:16:20","slug":"1061-dating-20","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=528","title":{"rendered":"1061. Dating (20)"},"content":{"rendered":"<p>Sherlock Holmes received a note with some strange strings: &#8220;Let&#8217;s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&amp;hgsfdk d&amp;Hyscvnm&#8221;. It took him only a minute to figure out that those strange strings are actually referring to the coded time &#8220;Thursday 14:04&#8221; &#8212; since the first common capital English letter (case sensitive) shared by the first two strings is the 4th capital letter &#8216;D&#8217;, representing the 4th day in a week; the second common character is the 5th capital letter &#8216;E&#8217;, 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 &#8216;s&#8217; at the 4th position, representing the 4th minute. Now given two pairs of strings, you are supposed to help Sherlock decode the dating time.<br \/>\n<b> Input Specification: <\/b><br \/>\nEach 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.<br \/>\n<b> Output Specification: <\/b><br \/>\nFor each test case, print the decoded time in one line, in the format &#8220;DAY HH:MM&#8221;, where &#8220;DAY&#8221; is a 3-character abbreviation for the days in a week &#8212; that is, &#8220;MON&#8221; for Monday, &#8220;TUE&#8221; for Tuesday, &#8220;WED&#8221; for Wednesday, &#8220;THU&#8221; for Thursday, &#8220;FRI&#8221; for Friday, &#8220;SAT&#8221; for Saturday, and &#8220;SUN&#8221; for Sunday. It is guaranteed that the result is unique for each case.<br \/>\n<b>Sample Input:<\/b><\/p>\n<pre>3485djDkxh4hhGE\n2984akDfkkkkggEdsb\ns&amp;hgsfdk\nd&amp;Hyscvnm<\/pre>\n<p><b>Sample Output:<\/b><\/p>\n<pre>THU 14:04<\/pre>\n<p>===========================================<br \/>\n\u9898\u76ee\u770b\u4e0a\u53bb\u633a\u7b80\u5355\uff0c\u81ea\u5df1\u505a\u7684\u65f6\u5019\u7c97\u5fc3\u5927\u610f\u8f7b\u89c6\u4e86\u3002<br \/>\n\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<br \/>\n1.\u7b2c\u4e00\u6b21\u6bd4\u5bf9\u7684\u662f\u4ece&#8217;A&#8217;-&#8216;G&#8217;\u4e4b\u5185\u7684\u76f8\u540c\u5b57\u6bcd\uff0c\u5176\u4ed6\u4efb\u4f55\u5b57\u7b26\u76f8\u540c\u7684\u65e0\u6548<br \/>\n2.\u7b2c\u4e8c\u6b21\u6bd4\u5bf9\u7684\u662f\u4ece&#8217;0&#8217;-&#8216;9&#8217;\u53ca&#8217;A&#8217;-&#8216;N&#8217;\u4e4b\u5185\u7684\u76f8\u540c\u5b57\u7b26\uff0c\u5176\u4ed6\u65e0\u6548<br \/>\n\u5410\u69fd\u4e0b\u7b2c\u4e00\u6b21\u7528VS2005\u611f\u89c9\u6bd4VS2012\u5dee\u4e86\u597d\u51e0\u6761\u8857\uff0c\u6839\u672c\u6ca1\u6709\u667a\u80fd\u63d0\u793a\uff0c\u4f30\u8ba1\u662f\u6211\u53d8\u6210\u4e60\u60ef\u4e0d\u597d\uff0c\u7f16\u8bd1\u9519\u4e86N\u6b21&#8230;\u4f46\u662f\u514d\u7814\u7684\u65f6\u5019\u4f30\u8ba1\u6ca1\u90a3\u4e48\u65b0\u7248\u672c\uff0c\u8fd8\u662f\u9002\u5e94\u4e00\u4e0b\u5427~<br \/>\n============================================<br \/>\n<code lang=\"c++\"><br \/>\n#include <iostream><br \/>\n#include <cstring><br \/>\n#include <iomanip><br \/>\nusing namespace std;<br \/>\nconst char* wkdays[] = {\"MON\", \"TUE\", \"WED\", \"THU\", \"FRI\", \"SAT\", \"SUN\"};<br \/>\nint main()<br \/>\n{<br \/>\n\tconst int BUFFER = 61;<br \/>\n\tchar str1[BUFFER];<br \/>\n\tint results[3]; \/\/\u5b58\u653e\u56db\u4e2a\u6570\u5b57\u7ed3\u679c<br \/>\n\t\/\/\u7b2c\u4e00\u6b21\u8bfb\u53d6<br \/>\n\tcin >> str1;<br \/>\n\tint len1 = strlen(str1);<br \/>\n\t\/\/\u7b2c\u4e8c\u6b21\u8bfb\u53d6<br \/>\n\tchar str2[BUFFER];<br \/>\n\tcin >> str2;<br \/>\n\tint len2 = strlen(str2);<br \/>\n\tint endIndex = (len1<len2)? len1:len2;\n\tbool firstTime = true;\n\tfor(int i=0; i<endIndex; i++)\n\t{\n\t\tbool digitFlag = false;\n\t\tint chrIndex = (int)str1[i] - 'A';\n\t\tint digIndex = (int)str1[i] - '0';\n\t\tif(firstTime)\n\t\t{\n\t\t\tif(chrIndex < 0 || chrIndex >=7 ) \/\/'G'<br \/>\n\t\t\t\tcontinue;<br \/>\n\t\t}<br \/>\n\t\telse<br \/>\n\t\t{<br \/>\n\t\t\tif(chrIndex < 0 || chrIndex >= 14) \/\/'N'<br \/>\n\t\t\t{<br \/>\n\t\t\t\tif(digIndex <0 || digIndex >9)<br \/>\n\t\t\t\t\tcontinue;<br \/>\n\t\t\t\tdigitFlag = true;\/\/\u662f\u4e2a\u6570\u5b57<br \/>\n\t\t\t}<br \/>\n\t\t}<br \/>\n\t\tif(str1[i] == str2[i])<br \/>\n\t\t{<br \/>\n\t\t\tif(firstTime)<br \/>\n\t\t\t{<br \/>\n\t\t\t\tresults[0] = chrIndex;<br \/>\n\t\t\t\tfirstTime = false;<br \/>\n\t\t\t}<br \/>\n\t\t\telse<br \/>\n\t\t\t{<br \/>\n\t\t\t\tresults[1] = digitFlag? (digIndex):(chrIndex + 10);<br \/>\n\t\t\t\tbreak;<br \/>\n\t\t\t}<br \/>\n\t\t}<br \/>\n\t}<br \/>\n\t\/\/\u7b2c\u4e09\u6b21\u8bfb\u53d6<br \/>\n\tchar str3[BUFFER];<br \/>\n\tchar str4[BUFFER];<br \/>\n\tcin >> str3 >> str4;<br \/>\n\tint len3 = strlen(str3);<br \/>\n\tint len4 = strlen(str4);<br \/>\n\tendIndex = (len3<len4)? len3:len4;\n\tfor(int i=0; i<endIndex; i++)\n\t{\n\t\tbool cond1 =  str3[i] >='a' && str3[i]<='z';\n\t\tbool cond2 = str3[i]>='A' && str3[i]<='Z';\n\t\tif(cond1 || cond2)\n\t\t{\n\t\t\tif(str3[i] == str4[i])\n\t\t\t{\n\t\t\t\tresults[2] = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tcout << wkdays[results[0]] << \" \" << setw(2) << std::setfill('0') << results[1] << \":\" << setw(2) << std::setfill('0') << results[2];\n\treturn 0;\n}\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sherlock Holmes received a note with some strange strings: &#8220;Let&#8217;s date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&amp;hgsfdk d&amp;Hyscvnm&#8221;. It took him only a minute to figure out that those strange strings are actually referring to the coded time &#8220;Thursday 14:04&#8221; &#8212; since the first common capital English letter (case sensitive) shared by the first two strings is the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[84],"class_list":["post-528","post","type-post","status-publish","format-standard","hentry","category-study","tag-pat"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=528"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/528\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}