{"id":788,"date":"2024-07-21T09:00:00","date_gmt":"2024-07-21T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=788"},"modified":"2024-06-25T17:41:40","modified_gmt":"2024-06-25T09:41:40","slug":"zerojudge-n764","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-n764\/","title":{"rendered":"ZeroJudge N764: Babelfish"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 10282 &#8211; Babelfish<\/h4>\n\n\n\n<p>\u4f60\u525b\u5f9e\u6ed1\u9435\u76e7\u642c\u5230\u4e00\u500b\u5927\u57ce\u5e02\u3002\u9019\u88e1\u7684\u4eba\u5011\u8aaa\u8457\u4e00\u7a2e\u4f60\u96e3\u4ee5\u7406\u89e3\u7684\u5916\u8a9e\u65b9\u8a00\u3002\u5e78\u904b\u7684\u662f\uff0c\u4f60\u6709\u4e00\u672c\u5b57\u5178\u53ef\u4ee5\u5e6b\u52a9\u4f60\u7406\u89e3\u4ed6\u5011\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>\u8f38\u5165\u5305\u542b\u6700\u591a 100,000 \u500b\u5b57\u5178\u689d\u76ee\uff0c\u4e4b\u5f8c\u662f\u4e00\u500b\u7a7a\u884c\uff0c\u518d\u4e4b\u5f8c\u662f\u4e00\u5247\u6700\u591a\u5305\u542b 100,000 \u500b\u55ae\u8a5e\u7684\u8a0a\u606f\u3002\u6bcf\u500b\u5b57\u5178\u689d\u76ee\u662f\u4e00\u884c\uff0c\u5305\u542b\u4e00\u500b\u82f1\u6587\u55ae\u8a5e\uff0c\u5f8c\u63a5\u4e00\u500b\u7a7a\u683c\uff0c\u518d\u5f8c\u63a5\u4e00\u500b\u5916\u8a9e\u55ae\u8a5e\u3002\u5b57\u5178\u4e2d\u6c92\u6709\u5916\u8a9e\u55ae\u8a5e\u6703\u91cd\u8907\u51fa\u73fe\u3002\u8a0a\u606f\u662f\u4e00\u7cfb\u5217\u7684\u5916\u8a9e\u55ae\u8a5e\uff0c\u6bcf\u884c\u4e00\u500b\u55ae\u8a5e\u3002\u8f38\u5165\u4e2d\u7684\u6bcf\u500b\u55ae\u8a5e\u6700\u591a\u5305\u542b 10 \u500b\u5c0f\u5beb\u5b57\u6bcd\u3002<\/td><td>\u8f38\u51fa\u662f\u5c07\u8a0a\u606f\u7ffb\u8b6f\u6210\u82f1\u6587\uff0c\u6bcf\u884c\u4e00\u500b\u55ae\u8a5e\u3002<strong>\u4e0d\u5728\u5b57\u5178\u4e2d\u7684\u5916\u8a9e\u55ae\u8a5e\u61c9\u7ffb\u8b6f\u70ba\u300ceh\u300d\u3002<\/strong><\/td><\/tr><tr><td>dog ogday<br>cat atcay<br>pig igpay<br>froot ootfray<br>loops oopslay<br><br>atcay<br>ittenkay<br>oopslay<\/td><td>cat<br>eh<br>loops<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u4f7f\u7528 getline \u4f86\u6536\u524d\u9762\u7684\u8cc7\u6599\uff0c\u5982\u679c getline \u5230\u7684\u8cc7\u6599\u70ba empty()\uff0c\u4ee3\u8868\u90a3\u662f\u7a7a\u884c\uff0c\u5c31\u958b\u59cb\u6536\u4e0b\u9762\u7684\u8cc7\u6599\u3002\u5c07 getline \u5230\u7684\u5b57\u4e32\u5206\u6210 a \u548c b\uff0c\u4e26\u4e14\u5ba3\u544a\u4e00\u500b Map&lt;string, string&gt;\uff0c\u4e26\u5c07 Map[b] \u8a2d\u5b9a\u6210 a\u3002<\/p>\n\n\n\n<p>\u6536\u4e0b\u9762\u7684\u8cc7\u6599\u6642\uff0c\u5982\u679c Map[\u6536\u5230\u7684\u5b57\u4e32].empty()\uff0c\u4ee3\u8868\u6c92\u6709\u7d00\u9304\uff0c\u8f38\u51fa\u300ceh\u300d\uff0c\u5426\u5247\u5c31\u8f38\u51fa Map[\u6536\u5230\u7684\u5b57\u4e32]\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=n764\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge N764: Babelfish<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;map&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    string str;\n    map&lt;string, string&gt;MAP;\n    while (getline(cin, str) && !str.empty()) {\n        string a, b;\n        for (int i = 0; i&lt;str.length(); i++) {\n            if (str[i] == &#39; &#39;) {\n                b = str.substr(i+1, str.length());\n                break;\n            }\n            a += str[i];\n        }\n        MAP[b] = a;\n    }\n    while (cin &gt;&gt; str) {\n        if (MAP[str].empty()) cout &lt;&lt; &quot;eh\\n&quot;;\n        else cout &lt;&lt; MAP[str] &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge N764\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 10282 &#8211; Babelfish \u4f60\u525b\u5f9e\u6ed1\u9435\u76e7\u642c\u5230\u4e00\u500b\u5927\u57ce\u5e02\u3002\u9019\u88e1\u7684\u4eba\u5011\u8aaa\u8457\u4e00\u7a2e\u4f60 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[18],"tags":[14,8,11,9],"class_list":["post-788","post","type-post","status-publish","format-standard","hentry","category-uva","tag-map","tag-8","tag-11","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=788"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/788\/revisions"}],"predecessor-version":[{"id":994,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/788\/revisions\/994"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}