{"id":267,"date":"2024-04-27T10:54:31","date_gmt":"2024-04-27T02:54:31","guid":{"rendered":"https:\/\/seanxd.com\/?p=267"},"modified":"2024-04-27T10:54:33","modified_gmt":"2024-04-27T02:54:33","slug":"zerojudge-f446","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-f446\/","title":{"rendered":"ZeroJudge F446: Expert Enough"},"content":{"rendered":"\n\n\n<h4 class=\"wp-block-heading\">\u540c\u984c\uff1aUVa 1237 &#8211; Expert Enough<\/h4>\n\n\n\n<p class=\"\">\u7d66\u4f60 N \u7b46\u8cc7\u6599\uff0c\u6bcf\u7b46\u544a\u8a34\u4f60\u5de5\u5ee0\u540d\u3001\u51fa\u7522\u904e\u8eca\u5b50\u6700\u4f4e\u548c\u6700\u9ad8\u50f9\u683c<\/p>\n\n\n\n<p class=\"\">\u5171\u6709 Q \u7d44\u8a62\u554f\uff0c\u6bcf\u7d44\u7d66\u4f60\u4e00\u500b\u6574\u6578 P<\/p>\n\n\n\n<p class=\"\">\u8f38\u51fa\u51fa\u7522\u8eca\u5b50\u50f9\u683c\u5340\u9593\u5305\u542b P \u7684\u5de5\u5ee0\u540d<\/p>\n\n\n\n<p class=\"\">\u5982\u679c\u6709\u591a\u9593\u540c\u6642\u7b26\u5408\u6216\u6c92\u6709\u534a\u9593\u7b26\u5408\uff0c\u8f38\u51fa\u300cUNDETERMINED\u300d<\/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\u884c\u6709\u500b T \u4ee3\u8868\u6e2c\u8cc7\u6578(T &lt;= 10)<br>\u6bcf\u7b46\u6e2c\u8cc7\u7684\u7b2c\u4e00\u884c\u6709\u4e00\u500b\u6b63\u6574\u6578 D \u4ee3\u8868\u5de5\u5ee0\u6578 (D &lt; 10000)<br>\u63a5\u4e0b\u4f86 D \u884c\u6bcf\u884c\u5206\u5225\u6709\u5de5\u5ee0\u540d(\u4e0d\u542b\u7a7a\u683c)\u548c\u50f9\u683c\u5340\u9593 L \u548c R (0 &lt; L &lt; R &lt; 1000000)<br>\u4e4b\u5f8c\u6709\u500b\u6b63\u6574\u6578 Q \u4ee3\u8868\u8a62\u554f\u6578<br>\u63a5\u4e0b\u4f86 Q \u884c\u6bcf\u884c\u6709\u4e00\u500b\u6b63\u6574\u6578 P \u4ee3\u8868\u8a62\u554f\u7684\u8eca\u5b50\u50f9\u9322 (0 &lt; P &lt; 1000000)<\/td><td>\u5982\u679c\u77e5\u9053\u662f\u54ea\u9593\u5de5\u5ee0\u751f\u7522\u7684\u5c31\u8f38\u51fa\u8a72\u5de5\u5ee0\u540d<br>\u5426\u5247\u8f38\u51fa\u300cUNDETERMINED\u300d<\/td><\/tr><tr><td>1<br>4<br>HONDA  10000  45000<br>PEUGEOT  12000  44000<br>BMW  30000  75900<br>CHEVROLET  7000  37000<br>4<br>60000<br>7500<br>5000<br>10000<\/td><td>BMW<br>CHEVROLET<br>UNDETERMINED<br>UNDETERMINED<\/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>Pair&lt;int, int> \u5c07\u6bcf\u500b\u5de5\u5ee0\u7684 L \u548c R \u5b58\u8d77\u4f86<\/strong>\uff0c\u5c07\u6bcf\u4e00\u500b <strong>Pair \u5b58\u5230\u4e00\u500b \u9663\u5217\/Vector<\/strong> \u4e2d\u3002<\/p>\n\n\n\n<p class=\"\">\u5ba3\u544a\u4e00\u500b <strong>Map<\/strong> \uff0c<strong>Key \u503c\u70ba\u525b\u525b\u6536\u5230\u7684 Pair&lt;int, int><\/strong>\uff0c<strong>Value \u503c\u5247\u662f\u5de5\u5ee0\u540d\u7a31<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u6bcf\u6536\u5230 <strong>P <\/strong>\u6642\uff0c\u4f7f\u7528 <strong>For \u8ff4\u5708<\/strong> \u628a<strong>\u5b58\u653e L \u548c R \u7684 \u9663\u5217\/Vector<\/strong> \u6383\u63cf\u4e00\u904d\uff0c\u5982\u679c P \u4ecb\u65bc\u67d0\u500b L \u8207 R \u7684\u5340\u9593\uff0c\u5247\u5148\u5c07<strong>\u7b54\u6848\u8a2d\u5b9a\u70ba\u76ee\u524d\u7684 L \u8207 R \u7684\u5de5\u5ee0\u540d\u7a31<\/strong> (Map \u7684 Value \u503c)\uff0c\u4e26\u4e14\u9810\u8a2d\u4e00\u500b<strong>\u6574\u6578\u300cCount\u300d \u8a08\u7b97\u6709\u5e7e\u5bb6\u5de5\u5ee0\u7b26\u5408\u7684\u8b8a\u6578\u5c07\u5176 +1<\/strong>\u3002<\/p>\n\n\n\n<p class=\"\">\u5982\u679c\u5728<strong> For\u8ff4\u5708 <\/strong>\u4e2d\u5224\u65b7\u5230\u76ee\u524d\u7684 <strong>Count \u5df2\u7d93\u5927\u65bc 1<\/strong> \u4e86\uff0c\u5247\u8f38\u51fa\u300cUNDETERMINED\u300d\u7136\u5f8c <strong>Break<\/strong> \u8ff4\u5708\u3002For\u8ff4\u5708 \u7d50\u675f\u4e4b\u5f8c\u5982\u679c<strong> Count = 1\uff0c\u90a3\u5c31\u5c07\u525b\u525b\u8a2d\u5b9a\u7684\u7b54\u6848\u505a\u8f38\u51fa<\/strong>\uff0c\u5982\u679c <strong>Count = 0\uff0c\u4ee3\u8868\u6c92\u6709\u9019\u500b\u50f9\u4f4d\u7684\u5de5\u5ee0<\/strong>\uff0c\u4e5f\u662f\u8f38\u51fa\u300cUNDETERMINED\u300d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=f446\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge F446: Expert Enough<\/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;\nusing namespace std;\n\npair&lt;int, int&gt; rtn(int a, int b)\n{\n    pair&lt;int, int&gt;tmp;\n    tmp.first = a;\n    tmp.second = b;\n    return tmp;\n}\n\nint main() {\n    int T;\n    cin &gt;&gt; T;\n    for (int i = 0; i&lt;T; i++)\n    {\n        int N;\n        cin &gt;&gt; N;\n        map&lt;pair&lt;int, int&gt;, string&gt;MAP;\n        vector&lt;pair&lt;int, int&gt;&gt;v;\n        for (int j = 0; j&lt;N; j++)\n        {\n            string name;\n            int low, high;\n            cin &gt;&gt; name &gt;&gt; low &gt;&gt; high;\n            pair&lt;int, int&gt;tmp = rtn(low, high);\n            v.push_back(tmp);\n            MAP[tmp] = name;\n        }\n        int Q;\n        cin &gt;&gt; Q;\n        for (int j = 0; j&lt;Q; j++)\n        {\n            int money, count = 0;\n            cin &gt;&gt; money;\n            string ans;\n            for (auto it:v)\n            {\n                if (money &gt;= it.first && money &lt;= it.second)\n                {\n                    count++;\n                    ans = MAP[it];\n                }\n                if (count &gt; 1)\n                {\n                    cout &lt;&lt; &quot;UNDETERMINED\\n&quot;;\n                    break;\n                }\n            }\n            if (count == 1) cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n            else if (count == 0) cout &lt;&lt; &quot;UNDETERMINED\\n&quot;;\n        }\n    }\n}\n\n\/\/ZeroJudge F446\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u984c\uff1aUVa 1237 &#8211; Expert Enough \u7d66\u4f60 N \u7b46\u8cc7\u6599\uff0c\u6bcf\u7b46\u544a\u8a34\u4f60\u5de5\u5ee0\u540d\u3001\u51fa\u7522\u904e [&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],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-uva","tag-map","tag-pair","tag-20","tag-8","tag-11"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/267","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=267"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":269,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/267\/revisions\/269"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}