{"id":447,"date":"2024-05-03T16:16:33","date_gmt":"2024-05-03T08:16:33","guid":{"rendered":"https:\/\/seanxd.com\/?p=447"},"modified":"2024-05-03T16:16:36","modified_gmt":"2024-05-03T08:16:36","slug":"zerojudge-d267","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-d267\/","title":{"rendered":"ZeroJudge D267: Letter Frequency"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 11577 &#8211; Letter Frequency<\/h4>\n\n\n\n<p class=\"\">\u6211\u5011\u5c0d\u4e00\u500b\u554f\u984c\u6709\u8208\u8da3\uff0c\u5230\u5e95\u5728\u9019\u884c\u6587\u5b57\u4e2d\u983b\u7387\u6700\u9ad8\u7684\u5b57\u6bcd\u662f\u4ec0\u9ebc?&nbsp;<\/p>\n\n\n\n<p class=\"\"><strong>\u53ef\u4ee5\u5ffd\u7565\u4e00\u4e9b\u975e\u5b57\u6bcd\u7684\u6587\u5b57<\/strong>\uff0c\u8981\u6ce8\u610f\u7684\u662f\u82e5\u662f<strong>\u51fa\u73fe\u4e86A\u5927\u5beb\u5b57\u6bcd\u8ddfa\u5c0f\u5beb\u90fd\u7b97\u662fa<\/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>\u7b2c\u4e00\u500b\u662f\u4ee3\u8868\u6709\u5e7e\u500b\u6e2c\u8a66\u8cc7\u6599\u3002<br>\u4e00\u884c\u5c31\u662f\u4e00\u500b\u6e2c\u8a66\u8cc7\u6599\uff0c<strong>\u9019\u4e00\u884c\u53ef\u80fd\u6709\u7a7a\u767d\uff0c\u4f46\u662f\u81f3\u5c11\u6709\u4e00\u500b\u5b57\u6bcd<\/strong>\uff0c\u4e00\u884c\u5168\u90e8\u7684\u5b57\u6bcd\u52a0\u8d77\u4f86\u4e0d\u8d85\u904e 200 \u500b<\/td><td>\u5c0d\u6bcf\u500b\u6e2c\u8a66\u8cc7\u6599\uff0c<strong>\u8f38\u51fa\u983b\u7387\u6700\u9ad8\u7684\u5c0f\u5beb\u5b57\u6bcd<\/strong>\u3002(<strong>\u5982\u679c\u8d85\u904e\u5169\u500b\u4e00\u6a23\uff0c\u8acb\u5b57\u5178\u7531\u5c0f\u6392\u5230\u5927<\/strong>)<\/td><\/tr><tr><td>1<br>Computers account for only 5% of the country&#8217;s commercial electricity consumption.<\/td><td>co<\/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=\"\">\u5148\u5c07<strong>\u6bcf\u500b\u5b57\u6bcd\u51fa\u73fe\u7684\u6b21\u6578\u5b58\u653e\u5230\u4e00\u500b Map \u4e2d<\/strong>\uff0c\u63a5\u4e0b\u4f86\u7528 Auto \u8dd1\u9019\u500b Map \u7684 For\u8ff4\u5708\uff0c\u4e26\u4e14\u518d\u958b\u4e00\u500b<strong>\u65b0\u7684 Map (Key\u662fint\uff0cValue\u662fVector)<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u5c07<strong>\u820a\u7684 Map \u4e2d\u7684\u503c\u4e58\u4ee5 -1 \u7576\u4f5c\u662f\u65b0\u7684 Map \u7684Key<\/strong>\uff0c\u4e26\u5c07\u5b57\u5143 Push_Back \u5230\u65b0\u7684 Map \u7684 Value \u4e2d\u3002<\/p>\n\n\n\n<p class=\"\">\u4e4b\u5f8c\u4e00\u6a23\u7528 Auto \u8dd1\u65b0\u7684 Map \u7684 For\u8ff4\u5708\uff0c\u5148\u5c07<strong> Vector \u9032\u884c\u6392\u5e8f\u5f8c\u5c07\u88e1\u9762\u7684\u5b57\u6bcd\u8f38\u51fa<\/strong>\uff0c\u7136\u5f8c<strong>\u5c31\u53ef\u4ee5Break\u9019\u500bFor\u8ff4\u5708\u56e0\u70ba\u53ea\u8981\u8f38\u51fa\u6700\u591a\u6b21\u6578\u7684\u5b57\u6bcd\u800c\u5df2<\/strong>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=d267\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge D267: Letter Frequency<\/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;\n#include &lt;vector&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    cin &gt;&gt; N;\n    string a;\n    getline(cin, a);\n    for (int i = 0; i&lt;N; i++)\n    {\n        string str;\n        getline(cin, str);\n        map&lt;char, int&gt;MAP;\n        for (int j = 0; j&lt;str.length(); j++)\n        {\n            if (isalpha(str[j]))\n            {\n                MAP[tolower(str[j])]++;\n            }\n        }\n        map&lt;int, vector&lt;char&gt;&gt;ans;\n        for (auto it:MAP)\n        {\n            ans[it.second * -1].push_back(it.first);\n        }\n        for (auto it:ans)\n        {\n            sort(it.second.begin(), it.second.end());\n            for (int j = 0; j&lt;it.second.size(); j++)\n            {\n                cout &lt;&lt; it.second[j];\n            }\n            cout &lt;&lt; &quot;\\n&quot;;\n            break;\n        }\n    }\n}\n\n\/\/ZeroJudge D267\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 11577 &#8211; Letter Frequency \u6211\u5011\u5c0d\u4e00\u500b\u554f\u984c\u6709\u8208\u8da3\uff0c\u5230\u5e95\u5728\u9019\u884c\u6587 [&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,23,20,8,11,19,9],"class_list":["post-447","post","type-post","status-publish","format-standard","hentry","category-uva","tag-map","tag-pair","tag-20","tag-8","tag-11","tag-19","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/447","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=447"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/447\/revisions"}],"predecessor-version":[{"id":448,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/447\/revisions\/448"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}