{"id":351,"date":"2024-04-28T11:42:03","date_gmt":"2024-04-28T03:42:03","guid":{"rendered":"https:\/\/seanxd.com\/?p=351"},"modified":"2024-04-28T11:42:05","modified_gmt":"2024-04-28T03:42:05","slug":"zerojudge-e507","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-e507\/","title":{"rendered":"ZeroJudge E507: Common Permutation"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 10252 &#8211; Common Permutation<\/h4>\n\n\n\n<p class=\"\">\u7d66\u5b9a\u5169\u500b\u7531\u5c0f\u5beb\u5b57\u6bcd\u7d44\u6210\u7684\u5b57\u4e32 a \u548c b\u3002<\/p>\n\n\n\n<p class=\"\"><strong>\u5370\u51fa\u6700\u9577\u7684\u5c0f\u5beb\u5b57\u4e32 x\uff0c\u4f7f\u5f97 x \u7d93\u904e\u91cd\u65b0\u6392\u5217\u5f8c\u70ba a \u7684\u5b50\u5e8f\u5217\uff0c\u4e14 x \u7d93\u904e\u91cd\u65b0\u6392\u5217\u5f8c\u70bab\u7684\u5b50\u5e8f\u5217<\/strong>\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 nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td>EOF \u8f38\u5165\uff0c\u9023\u7e8c\u7684\u5169\u884c\u70ba\u4e00\u7d44\uff0c\u7b2c\u4e00\u884c\u70ba\u5b57\u4e32 a\uff0c\u7b2c\u4e8c\u884c\u70ba\u5b57\u4e32 b\u3002<br>1\uff5e2 \u884c\u70ba\u4e00\u7d44\u8f38\u5165\uff0c3\uff5e4 \u884c\u70ba\u4e00\u7d44\u8f38\u5165\uff0c\u4f9d\u6b64\u985e\u63a8\u3002<br>\u6bcf\u500b\u5b57\u4e32\u6700\u591a\u5305\u6db51000\u500b\u5c0f\u5beb\u5b57\u6bcd\u3002<\/td><td>\u5c0d\u65bc\u6bcf\u7d44\u8f38\u5165\uff0c\u8f38\u51fa\u672c\u984c\u8981\u6c42 a \u548c b \u7684 x\u3002<br><strong>\u5982\u679c\u6709\u591a\u7d44\u7b26\u5408\u7684x<br>\u8acb\u5370\u51fa\u5b57\u6bcd\u9806\u5e8f\u7531\u5c0f\u5230\u5927\u6392\u5217\u7684\u90a3\u4e00\u500b\u3002<\/strong><\/td><\/tr><tr><td>pretty<br>women<br>walking<br>down<br>the<br>street<\/td><td>e<br>nw<br>et<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\">\u4f7f\u7528<strong> Map \u4f86\u7d00\u9304 a \u7684\u6709\u54ea\u4e9b\u5b57\u5143<\/strong>\uff0c\u518d\u8dd1 <strong>b \u7684 For\u8ff4\u5708 \u770b\u9019\u500b\u5b57\u5143\u6709\u6c92\u6709\u5728A\u6709\u51fa\u73fe\u904e\uff0c\u5982\u679c\u6709\u7684\u8a71\u5c31\u5728\u7b54\u6848\u7684 Map \u88e1\u9762\u7d00\u9304<\/strong>\uff0c\u4e26\u4e14<strong>\u5c07 A \u7684 Map -1<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u4f7f\u7528 <strong>for (auto it:Map)<\/strong> \u8dd1 \u7b54\u6848Map \u7684\u8ff4\u5708\u5c07\u5b57\u5143\u8f38\u51fa\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=e507\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge E507: Common Permutation<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><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 a, b;\n    while (cin &gt;&gt; a &gt;&gt; b)\n    {\n        map&lt;char, int&gt;A;\n        map&lt;char, int&gt;ans;\n        for (int i = 0; i&lt;a.length(); i++)\n        {\n            A[a[i]]++;\n        }\n        for (int i = 0; i&lt;b.length(); i++)\n        {\n            if (A[b[i]] &gt; 0)\n            {\n                ans[b[i]]++;\n                A[b[i]]--;\n            }\n        }\n        for (auto it:ans)\n        {\n            for (int i = 0; i&lt;it.second; i++)\n            {\n                cout &lt;&lt; it.first;\n            }\n        }\n        cout &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge E507\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 10252 &#8211; Common Permutation \u7d66\u5b9a\u5169\u500b\u7531\u5c0f\u5beb\u5b57\u6bcd\u7d44\u6210\u7684\u5b57\u4e32  [&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-351","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\/zh\/wp-json\/wp\/v2\/posts\/351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=351"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/351\/revisions"}],"predecessor-version":[{"id":352,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/351\/revisions\/352"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}