{"id":1180,"date":"2022-05-29T08:43:19","date_gmt":"2022-05-29T00:43:19","guid":{"rendered":"https:\/\/sanlangcode.com\/?p=1180"},"modified":"2022-05-29T08:43:19","modified_gmt":"2022-05-29T00:43:19","slug":"1180","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2022\/05\/29\/1180\/","title":{"rendered":"HJ66 \u914d\u7f6e\u6587\u4ef6\u6062\u590d"},"content":{"rendered":"\n<pre id=\"block-8783c92a-e132-4d81-8bdb-0065bf3b722b\" class=\"wp-block-preformatted\"><strong>\u7b97\u6cd5\u6d41\u7a0b<\/strong>\uff1a<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u4e24\u4e2a\u53d8\u91cf\u5206\u522b\u8bb0\u5f55\u5339\u914d\u6210\u529f\u7684\u547d\u4ee4\u6570\u91cf\u3001\u5339\u914d\u6210\u529f\u540e\u5728map\u7684key<\/li><li>\u5206\u8f93\u5165\u547d\u4ee4\u7684\u957f\u5ea6\uff0c\u5206\u60c5\u51b5\u904d\u5386\u6bcf\u4e2a\u547d\u4ee4\u8fdb\u884c\u524d\u7f00\u7684\u5339\u914d<\/li><li>\u5339\u914d\u6210\u529f\u540e\u66f4\u65b0\u4e24\u4e2a\u53d8\u91cf<\/li><li>\u6700\u540e\u5224\u65ad\u5339\u914d\u6210\u529f\u7684\u6b21\u6570\uff0c\u7ed3\u679c\u4e3a1\u624d\u8868\u793a\u5339\u914d\u4e0a<\/li><\/ul>\n\n\n\n<div class=\"wp-block-group has-black-color has-very-light-gray-to-cyan-bluish-gray-gradient-background has-text-color has-background\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-code has-medium-font-size\"><code>import java.util.*;\npublic class Main{\n    public static void main(String&#91;]args){\n        Scanner sc=new Scanner(System.in);\n        while(sc.hasNext()){\n            String s=sc.nextLine();\n            recover(s);\n        }\n    }\n    public static void recover(String s){\n        String&#91;] strings = {\"reset\",\"reset board\",\"board add\",\"board delete\",\"reboot backplane\",\"backplane abort\"};\n        Map&lt;String,String>map=new HashMap&lt;>();\n        map.put(\"reset\",\"reset what\");\n        map.put(\"reset board\",\"board fault\");\n        map.put(\"board add\",\"where to add \");\n        map.put(\"board delete\",\"no board at all\");\n        map.put(\"reboot backplane\",\"impossible\");\n        map.put(\"backplane abort\",\"install first\");\n        String ERROR = \"unknown command\";\n        String&#91;] inputArr = s.split(\" \");\n        \/\/ \u8f93\u5165\u7684\u547d\u4ee4\u957f\u5ea6\u4e3a1\n        if (inputArr.length==1){\n            String input = inputArr&#91;0];\n            String cmd = strings&#91;0].substring(0, input.length());\n            if (cmd.equals(input)){\n                System.out.println(\"reset what\");\n            }else {\n                System.out.println(ERROR);\n            }\n        }else { \n        \t\/\/ \u5339\u914d\u6210\u529f\u7684\u547d\u4ee4\u6570\u91cf\n        \tint count = 0;\n            \/\/ \u5339\u914d\u6210\u529f\u540e\u5728map\u7684key\n            String key = \"\";\n            \/\/ \u7a77\u4e3e\u4e8c\u5b57\u4e32\u7684\u547d\u4ee4\n            for (int i = 1 ; i &lt; strings.length ; i++){\n                String input1 = inputArr&#91;0], input2 = inputArr&#91;1];\n                String command = strings&#91;i];\n                String&#91;] cmd = command.split(\" \");\n                if (cmd.length==2){\n                    String cmd1 = cmd&#91;0], cmd2 = cmd&#91;1];\n                    \/\/ \u8f93\u5165\u7684\u547d\u4ee4\u957f\u5ea6\u5929\u957f\uff0c\u4e0d\u5339\u914d\u8be5\u547d\u4ee4\n                    if (cmd1.length() &lt; input1.length() || cmd2.length() &lt; input2.length()){\n                        continue;\n                    }\n                    String s1 = cmd1.substring(0, input1.length());\n                    String s2 = cmd2.substring(0, input2.length());\n                    \/\/ \u5339\u914d\u524d\u7f00\n                    if (s1.equals(input1) &amp;&amp; s2.equals(input2)){\n                    \t\/\/ \u5339\u914d\u6210\u529f\u540e\u7684\n                        key = command;\n                        \/\/ \u7edf\u8ba1\u5339\u914d\u6210\u529f\u7684\u6b21\u6570\n                        count++;\n                    }\n                }\n            }\n            \/\/ \u53ea\u80fd\u5339\u914d\u6210\u529f\u4e00\u4e2a\n            if (count == 1){\n                System.out.println(map.get(key));\n            }else {\n                System.out.println(ERROR);\n            }\n        }\n    }\n\n}\n<\/code><\/pre>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7b97\u6cd5\u6d41\u7a0b\uff1a \u4e24\u4e2a\u53d8\u91cf\u5206\u522b\u8bb0\u5f55\u5339\u914d&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1122,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4],"tags":[],"class_list":["post-1180","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-4"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=1180"}],"version-history":[{"count":0,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1180\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media\/1122"}],"wp:attachment":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=1180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=1180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=1180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}