{"id":1255,"date":"2024-11-09T09:00:00","date_gmt":"2024-11-09T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=1255"},"modified":"2024-10-15T07:49:25","modified_gmt":"2024-10-14T23:49:25","slug":"zerojudge-a349","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-a349\/","title":{"rendered":"ZeroJudge A349: Decoding Commands"},"content":{"rendered":"\n\n\n<p>\u5fd7\u8c6a\u5bb6\u88e1\u6709\u4e00\u90e8\u5f88\u73cd\u8cb4\u7684\u9aa8\u8463\u96fb\u8166\u3002\u9019\u90e8\u96fb\u8166\u53ea\u6709\u56db\u500b 16-\u4f4d\u5143 (bit) \u7684\u66ab\u5b58\u5668\u548c\u516b\u500b\u5b57\u7d44 (word\uff0c\u6bcf\u500b\u5b57\u7d44\u4ea6\u70ba 16-bit) \u7684\u4e3b\u8a18\u61b6\u9ad4\u3002\u5b83\u7684\u4e2d\u592e\u8655\u7406\u5668\u7684\u90e8\u4efd\u6307\u4ee4\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>\u6307\u4ee4<\/td><td>\u6307\u4ee4\u683c\u5f0f<\/td><td>\u6307\u4ee4\u610f\u7fa9<\/td><\/tr><tr><td>LOAD<\/td><td>LOAD RD MS<\/td><td>\u5c07\u8a18\u61b6\u9ad4\u4f4d\u5740 MS \u7684\u5b57\u7d44\u6578\u503c\u8f09\u5165\u66ab\u5b58\u5668 RD<\/td><\/tr><tr><td>STORE<\/td><td>STORE MD RS<\/td><td>\u5c07\u66ab\u5b58\u5668 RS \u7684\u6578\u503c\u5b58\u56de\u8a18\u61b6\u9ad4\u4f4d\u5740 MD \u7684\u5b57\u7d44<\/td><\/tr><tr><td>ADD<\/td><td>ADD RD RS1 RS2<\/td><td>\u5c07\u66ab\u5b58\u5668 RS1 \u548c RS2 \u7684\u6578\u503c\u548c\u5b58\u5165\u66ab\u5b58\u5668 RD<\/td><\/tr><tr><td>MOVE<\/td><td>MOVE RD RS<\/td><td>\u5c07\u66ab\u5b58\u5668 RS \u7684\u6578\u503c\u5b58\u5165\u66ab\u5b58\u5668 RD<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5047\u8a2d\u66ab\u5b58\u5668\u7684\u7de8\u865f\u5f9e 0 \u958b\u59cb\uff0c\u4e3b\u8a18\u61b6\u9ad4\u4f4d\u5740\u4e5f\u540c\u6a23\u5f9e 0 \u958b\u59cb\u3002\u82e5\u5df2\u77e5\u4e3b\u8a18\u61b6\u9ad4\u4f4d\u5740 0 \u548c 1 \u7684\u6578\u503c\u70ba 123 \u548c 456\uff0c\u4ee5\u4e0b\u7a0b\u5f0f\u7247\u6bb5\u57f7\u884c\u5f8c\u6703\u5c07 579 (123 + 456) \u5b58\u5165\u4e3b\u8a18\u61b6\u9ad4\u4f4d\u5740 2 \u7684\u5b57\u7d44\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>LOAD 0 0<br>LOAD 1 1<br>ADD 2 0 1<br>STORE 2 2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u8acb\u4f60\u64b0\u5beb\u4e00\u500b\u7a0b\u5f0f\uff0c\u8b80\u5165\u4e00\u4e32\u6307\u4ee4\uff08\u53ea\u6703\u51fa\u73fe\u4e0a\u8ff0\u56db\u7a2e\u6307\u4ee4\uff09\uff0c\u6a21\u64ec\u9019\u4e32\u6307\u4ee4\u57f7\u884c\u7684\u7d50\u679c\uff0c\u4e26\u5c07\u57f7\u884c\u5f8c\u7b2c\u4e00\u500b\u66ab\u5b58\u5668\u548c\u7b2c\u4e00\u500b\u8a18\u61b6\u9ad4\u5b57\u7d44\u7684\u5167\u5bb9\u986f\u793a\u51fa\u4f86\u3002<\/p>\n\n\n\n<p>\u5047\u8a2d 1\uff1a\u6240\u6709\u66ab\u5b58\u5668\u7684\u521d\u59cb\u6578\u503c\u7686\u70ba 0\u3002<\/p>\n\n\n\n<p>\u5047\u8a2d 2\uff1a\u8a08\u7b97\u904e\u7a0b\u4e2d\u4e0d\u6703\u6709\u6ea2\u4f4d\u60c5\u5f62\u767c\u751f\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>\u7b2c\u4e00\u884c\u81f3\u7b2c\u516b\u884c\u70ba\u516b\u500b\u8a18\u61b6\u9ad4\u5b57\u7d44\u7684\u521d\u59cb\u6578\u503c\u3002<br>\u7b2c\u4e5d\u884c\u6709\u4e00\u500b\u6b63\u6574\u6578 N (1 \u2264 N \u2264 50)\uff0c\u4ee3\u8868\u6307\u4ee4\u500b\u6578\u3002<br>\u7b2c\u5341\u884c\u958b\u59cb\u6709 N \u884c\uff0c\u6bcf\u4e00\u884c\u70ba\u4e00\u500b\u6307\u4ee4\u3002<\/td><td>\u8acb\u4f9d\u5e8f\u8f38\u51fa\u7b2c\u4e00\u500b\u66ab\u5b58\u5668\uff08\u7de8\u865f 0 \u865f\uff09\u548c\u7b2c\u4e00\u500b\u8a18\u61b6\u9ad4\u5b57\u7d44\uff08\u7de8\u865f 0 \u865f\uff09\u7684\u6578\u503c\u5167\u5bb9\u3002<\/td><\/tr><tr><td>123<br>456<br>0<br>0<br>0<br>0<br>0<br>0<br>4<br>LOAD 0 0<br>LOAD 1 1<br>ADD 2 0 1<br>STORE 2 2<\/td><td>123<br>123<\/td><\/tr><tr><td>100<br>200<br>300<br>400<br>0<br>0<br>0<br>0<br>7<br>LOAD 0 0<br>LOAD 1 1<br>ADD 2 0 1<br>LOAD 0 2<br>MOVE 3 2<br>ADD 0 3 1<br>STORE 3 0<\/td><td>500<br>100<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">ZeroJudge A349 \u7bc4\u4f8b\u6e2c\u8cc7<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p>\u5ba3\u544a\u5169\u500b\u7a7a\u7684\u9663\u5217\uff0c\u4e26\u4e14\u4f7f\u7528\u5224\u65b7\u5f0f\u6536\u8cc7\u6599\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=a349\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge A349: \u6307\u4ee4\u89e3\u8b6f\u5668<\/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;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int num[8] = {}, tempMem[8] = {};\n    for (int i = 0; i &lt; 8; i++) {\n        cin &gt;&gt; num[i];\n        tempMem[i] = -1;\n    }\n    int N;\n    cin &gt;&gt; N;\n    for (int i = 0; i&lt;N; i++) {\n        string str;\n        cin &gt;&gt; str;\n        if (str == &quot;LOAD&quot;) {\n            int RD, MS;\n            cin &gt;&gt; RD &gt;&gt; MS;\n            tempMem[RD] = num[MS];\n        }\n        else if (str == &quot;STORE&quot;) {\n            int MD, RS;\n            cin &gt;&gt; MD &gt;&gt; RS;\n            num[MD] = tempMem[RS];\n        }\n        else if (str == &quot;ADD&quot;) {\n            int RD, RS1, RS2;\n            cin &gt;&gt; RD &gt;&gt; RS1 &gt;&gt; RS2;\n            tempMem[RD] = tempMem[RS1] + tempMem[RS2];\n        }\n        else if (str == &quot;MOVE&quot;) {\n            int RD, RS;\n            cin &gt;&gt; RD &gt;&gt; RS;\n            tempMem[RD] = tempMem[RS];\n        }\n    }\n    cout &lt;&lt; tempMem[0] &lt;&lt; &quot;\\n&quot; &lt;&lt; num[0] &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge A349\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5fd7\u8c6a\u5bb6\u88e1\u6709\u4e00\u90e8\u5f88\u73cd\u8cb4\u7684\u9aa8\u8463\u96fb\u8166\u3002\u9019\u90e8\u96fb\u8166\u53ea\u6709\u56db\u500b 16-\u4f4d\u5143 (bit) \u7684\u66ab\u5b58\u5668\u548c\u516b\u500b\u5b57\u7d44 (word\uff0c\u6bcf\u500b [&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":[29],"tags":[20,8,11,9],"class_list":["post-1255","post","type-post","status-publish","format-standard","hentry","category-zerojudge-","tag-20","tag-8","tag-11","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1255","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=1255"}],"version-history":[{"count":3,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1255\/revisions"}],"predecessor-version":[{"id":1258,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/1255\/revisions\/1258"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=1255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=1255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=1255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}