{"id":3887,"date":"2023-01-13T17:02:45","date_gmt":"2023-01-13T09:02:45","guid":{"rendered":"https:\/\/codingbar.ai\/content\/?p=3887"},"modified":"2023-09-07T09:15:04","modified_gmt":"2023-09-07T01:15:04","slug":"apcs202301python","status":"publish","type":"post","link":"https:\/\/codingbar.ai\/content\/apcs202301python\/","title":{"rendered":"APCS 2023\u5e741\u6708 \u89e3\u984c\u601d\u7dd2+Python\u53c3\u8003\u4f5c\u6cd5"},"content":{"rendered":"\n<p class=\"has-text-align-center\"><span style=\"color: #687fff;\" class=\"stk-highlight\"><strong>\u60f3\u77e5\u90532022\u5e7410\u6708\u89e3\u984c\u53ef\u4ee5\u9ede\u6b64\u9023\u7d50<\/strong><\/span><span style=\"color: #4170ff;\" class=\"stk-highlight\"> <a href=\"https:\/\/codingbar.ai\/content\/2022\/10\/26\/apcs-2022%e5%b9%b410%e6%9c%88-%e8%a7%a3%e9%a1%8c%e6%80%9d%e7%b7%92python%e5%8f%83%e8%80%83%e4%bd%9c%e6%b3%95\/\" data-type=\"URL\" data-id=\"https:\/\/codingbar.ai\/content\/2022\/10\/26\/apcs-2022%e5%b9%b410%e6%9c%88-%e8%a7%a3%e9%a1%8c%e6%80%9d%e7%b7%92python%e5%8f%83%e8%80%83%e4%bd%9c%e6%b3%95\/\" target=\"_blank\" rel=\"noreferrer noopener\">10\u6708\u4efd\u89e3\u984c<\/a><\/span><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u6587\u7ae0\u76ee\u9304<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"\u986f\u793a\/\u96b1\u85cf\u5167\u5bb9\u76ee\u9304\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/codingbar.ai\/content\/apcs202301python\/#%E5%AF%AB%E5%AE%8CAPCS%E9%A1%8C%E7%9B%AE%E5%BE%8C%E7%9A%84%E7%A2%8E%E7%A2%8E%E5%BF%B5\" >\u5beb\u5b8cAPCS\u984c\u76ee\u5f8c\u7684\u788e\u788e\u5ff5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/codingbar.ai\/content\/apcs202301python\/#ZeroJudge_%E9%A1%8C%E7%9B%AE\" >ZeroJudge \u984c\u76ee<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/codingbar.ai\/content\/apcs202301python\/#%E7%A8%8B%E5%BC%8F%E8%80%83%E8%A9%A6\" >\u7a0b\u5f0f\u8003\u8a66<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/codingbar.ai\/content\/apcs202301python\/#%E9%80%A0%E5%AD%97%E7%A8%8B%E5%BC%8F\" >\u9020\u5b57\u7a0b\u5f0f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/codingbar.ai\/content\/apcs202301python\/#%E5%85%88%E5%8A%A0%E5%BE%8C%E4%B9%98%E8%88%87%E5%87%BD%E6%95%B8\" >\u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/codingbar.ai\/content\/apcs202301python\/#%E6%A9%9F%E5%99%A8%E5%87%BA%E7%A7%9F\" >\u6a5f\u5668\u51fa\u79df<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AF%AB%E5%AE%8CAPCS%E9%A1%8C%E7%9B%AE%E5%BE%8C%E7%9A%84%E7%A2%8E%E7%A2%8E%E5%BF%B5\"><\/span><strong>\u5beb\u5b8cAPCS\u984c\u76ee\u5f8c\u7684\u788e\u788e\u5ff5<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u672c\u6b21APCS\u984c\u76ee\u6709\u9ede\u4ee4\u4eba\u611f\u5230\u610f\u5916\uff0c\u76f8\u8f03\u65bc\u4e4b\u524d\u7684\u984c\u76ee\u8003\u7684\u89c0\u5ff5\u6709\u9ede\u7565\u70ba\u4e0d\u540c\u3002<br>\u7b2c\u4e00\u984c\u662f\u70ba\u8fed\u4ee3\u7684\u57fa\u672c\u984c\uff0c\u53ea\u9808\u770b\u6e05\u984c\u76ee\u5373\u53ef\u7c21\u55ae\u5730\u5229\u7528\u8ff4\u5708\u8a08\u7b97\u51fa\u7b54\u6848\u3002<br>\u7b2c\u4e8c\u984c\u662f\u96d6\u7136\u662f\u5b57\u4e32\u8655\u7406\uff0c\u4f46\u500b\u4eba\u8a8d\u70ba\u6bd4\u8f03\u504f\u5411\u77e9\u9663\uff0c\u5229\u7528\u77e9\u9663\u53ef\u4ee5\u5feb\u901f\u5730\u89e3\u51fa\u6b64\u984c\u7b54\u6848\u3002<br>\u7b2c\u4e09\u984c\u8003\u9a57\u4e5f\u662f\u5b57\u4e32\u8655\u7406\uff0c\u4f46\u7d50\u5408\u4e86\u905e\u8ff4\u6216\u8005\u662fstack\u7684\u6982\u5ff5\uff0c\u4f46\u5c31\u7b97\u662f\u4e0d\u719f\u6089\u905e\u8ff4\u4ee5\u53castack\u4f9d\u7136\u53ef\u4ee5\u4f7f\u7528\u666e\u901a\u65b9\u6cd5\u7372\u5f9730\u5206\uff0c\u7b97\u662f\u826f\u5fc3\u984c\u3002\u7279\u5225\u7528Python\u5beb\u53ef\u4ee5\u7528\u7279\u6b8a\u65b9\u6cd5\u89e3\u7b54\uff0c\u65b9\u4fbf\u5f88\u591a<br>\u7b2c\u56db\u984c\u5c31\u662f\u4f7f\u7528\u8caa\u5a6a\u6f14\u7b97\u6cd5\uff0c\u53ea\u8981\u6709\u60f3\u5230\u5169\u500b\u89e3\u984c\u91cd\u9ede\uff1a1.\u4f9d\u7d50\u675f\u6642\u9593\u6392\u5e8f 2. \u5bcc\u6709\u64cd\u6b7b\u6a5f\u5668\u7684\u7cbe\u795e\uff0c\u6709\u5b78\u904e\u57fa\u672c\u8a9e\u6cd5\u7684\u4eba\u61c9\u8a72\u90fd\u53ef\u4ee5\u7c21\u55ae\u5730\u5beb\u51fa\u9019\u4e00\u984c\u3002<br>\u9019\u56db\u984c\u5beb\u5b8c\u7684\u8a71\uff0c\u500b\u4eba\u8a8d\u70ba\u62ff\u5230\u56db\u7d1a\u5206\u662f\u6bd4\u4ee5\u524d\u8f15\u9b06\u7684\uff0c\u53ea\u8981\u597d\u597d\u5730\u628a\u524d\u5e7e\u5b50\u984c\u56de\u7b54\u51fa\u4f86\u5373\u53ef\u3002\u4f46\u662f\u8981\u7372\u5f97\u4e94\u7d1a\u5206\u7684\u8a71\u5c31\u8981\u7b54\u5c0d\u5168\u90e8\u984c\u76ee\u3002\u9019\u6b21\u4e94\u7d1a\u5206\u7684\u4eba\u6578\u61c9\u8a72\u6703\u6bd4\u4e0a\u6b21\u5c11\u5427\uff1f<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"ZeroJudge_%E9%A1%8C%E7%9B%AE\"><\/span>ZeroJudge \u984c\u76ee<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ol>\n<li><a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j605\" target=\"_blank\" data-type=\"URL\" data-id=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j605\" rel=\"noreferrer noopener nofollow\">\u7a0b\u5f0f\u8003\u8a66<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j606\" target=\"_blank\" data-type=\"URL\" data-id=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j606\" rel=\"noreferrer noopener nofollow\">\u9020\u5b57\u7a0b\u5f0f<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j607\" target=\"_blank\" data-type=\"URL\" data-id=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j607\" rel=\"noreferrer noopener nofollow\">\u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j608\" target=\"_blank\" data-type=\"URL\" data-id=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=j608\" rel=\"noreferrer noopener nofollow\">\u6a5f\u5668\u51fa\u79df<\/a><\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%A8%8B%E5%BC%8F%E8%80%83%E8%A9%A6\"><\/span>\u7a0b\u5f0f\u8003\u8a66<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u76f4\u63a5\u9023TimeStamp<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"\u3010APCS\u89e3\u5bc6\u3011112\u5e74\u4e00\u6708APCS\u5be6\u4f5c\u984c\u89e3\u6790\uff1a\u7a0b\u5f0f\u8003\u8a66\u3001\u9020\u5b57\u7a0b\u5f0f\u3001\u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578\u3001\u6a5f\u5668\u51fa\u79df\" width=\"1290\" height=\"726\" src=\"https:\/\/www.youtube.com\/embed\/sgFaT7tsAtU?start=8&#038;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u984c\u76ee\u7c21\u8ff0\uff1a<br>\u9996\u5148\u6211\u5011\u77e5\u9053\u8f38\u5165\u7e3d\u5171\u6709K\u7b46\u8cc7\u6599\uff0c\u6bcf\u7b46\u8cc7\u6599\u6703\u6709\u5169\u500b\u5143\u7d20\u5206\u5225\u662f\u6642\u9593(t)\u8ddf\u5206\u6578(s)\uff0c\u7136\u5f8c\u984c\u76ee\u8981\u6c42\u6211\u5011\u8981\u627e\u5230\u6700\u9ad8\u5206\u7684\u6642\u9593\u4ee5\u53ca\u8a08\u7b97\u6700\u7d42\u7684\u6210\u7e3e\uff0c\u9019\u908a\u8981\u6ce8\u610f\u6700\u7d42\u6210\u7e3e\u4e0d\u5b8c\u5168\u662f\u6700\u9ad8\u5206\u6210\u7e3e\u5594\uff01\u9084\u9700\u8981\u7d93\u904e\u4e00\u4e9b\u51fd\u5f0f\u904b\u7b97\u624d\u53ef\u4ee5\uff0c\u5426\u5247\u9019\u4e00\u984c\u5c31\u592a\u7c21\u55ae\u4e86\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/APCS11201p1.png?resize=170%2C472&#038;ssl=1\" alt=\"APCS Python \u7a0b\u5f0f\u8003\u8a66\" class=\"wp-image-3890\" width=\"170\" height=\"472\" srcset=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/APCS11201p1.png?resize=369%2C1024&amp;ssl=1 369w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/APCS11201p1.png?resize=108%2C300&amp;ssl=1 108w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/APCS11201p1.png?resize=553%2C1536&amp;ssl=1 553w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/APCS11201p1.png?w=711&amp;ssl=1 711w\" sizes=\"(max-width: 170px) 100vw, 170px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p>\u770b\u5411\u4e0a\u9762\u7684\u5716\uff0c\u4f60\u6703\u770b\u5230t\u8ddfs\u3002\u90a3\u984c\u76ee\u88e1\u9762\u6709\u63d0\u5230\uff0ct\u662f\u56b4\u683c\u905e\u589e\uff0c\u6240\u4ee5\u4e00\u5b9a\u6703\u6309\u7167\u9806\u5e8f\u6392\u597d(\u4f46\u8001\u5be6\u8aaa\u9019\u984c\u8ddft\u7684\u5927\u5c0f\u9806\u5e8f\u4e5f\u7121\u95dc\u5c31\u662f\u4e86)\uff0c\u800cs\u6703\u662f-1~100\u4e4b\u9593\u7684\u6578\u5b57\uff0c\u5728\u9019\u4f8b\u5b50\u4f60\u6703\u770b\u5230\uff0c\u6700\u9ad8\u7684\u5206\u6578\u662f60\u5206\uff0c\u800c\u4e14\u72af\u56b4\u91cd\u932f\u5169\u6b21\u3002\u90a3\u63a5\u4e0b\u4f86\u6211\u5011\u5c31\u8981\u5957\u7528\u984c\u76ee\u6240\u63d0\u5230\u7684\u516c\u5f0f\u56c9\uff0c\u516c\u5f0f\u9019\u908a\u5beb\u5230\uff0c\u6700\u7d42\u6211\u5011\u8981\u7d66\u4e88\u7684\u7b54\u6848\u70ba<strong>maxScore \u2013 totalSubmit(\u4e5f\u5c31\u662fK)\u2013 error*2<\/strong>\u3002\u90a3\u9019\u908a\u8a08\u7b97\u5b8c\u7562\u5f8c\u6703\u5f97\u523051\uff0c\u9019\u5c31\u6703\u662f\u9019\u4f8b\u5b50\u7684\u7b54\u6848\u3002<\/p>\n\n\n\n<p>\u6709\u4e86\u4ee5\u4e0a\u7684\u6982\u5ff5\u5f8c\u6211\u5927\u6982\u4e0a\u4e00\u4e0b\u89e3\u984c\u6d41\u7a0b<br><strong>\u8f38\u5165\uff1a<\/strong><br><strong>1. \u6b63\u6574\u6578K<\/strong><br><strong>2. K\u884c\uff0ct(\u63d0\u4ea4\u6642\u9593) \u548c s(\u5206\u6578)<\/strong><br><strong>\u908f\u8f2f\uff1a<\/strong><br><strong>1. \u8a18\u9304\u9ad8\u5149\u6642\u523b -&gt; maxScore<\/strong><br><strong>2. \u7d00\u9304Error\u6b21\u6578 -&gt; error<\/strong><br><strong>\u8f38\u51fa \uff1a<\/strong><br><strong>1. maxScore &#8211; totalSubmit (K) \u2013 error*2<\/strong><br><strong>2. \u82e5\u5206\u6578\u5c0f\u65bc0\u5247\u4ee50\u8a08\u7b97<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: \u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~; toolbar: true; notranslate\" title=\"\u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~\">\nK = int(input())# 1. \u6b63\u6574\u6578K\n# 2. K\u884c\uff0ct(\u63d0\u4ea4\u6642\u9593) \u548c s(\u5206\u6578)\nmaxScore,time,error = -1,0,0\nfor i in range(K):\n    t,s = &#x5B;int(i) for i in input().split()]\n    if s&gt;maxScore:#\u8a18\u9304\u9ad8\u5149\u6642\u523b -&gt; maxScore\n        maxScore = s\n        time = t\n    if s == -1:#\u7d00\u9304Error\u6b21\u6578 -&gt; error\n        error += 1\nans = maxScore - K - 2*error#maxScore - totalSubmit (K) \u2013 error*2\nif ans &lt; 0:#\u82e5\u5206\u6578\u5c0f\u65bc0\u5247\u4ee50\u8a08\u7b97\n    ans = 0\nprint(ans,time)\n<\/pre><\/div>\n\n\n<p>\u4ee5\u4e0a\u70ba\u89e3\u984c\u904e\u7a0b\uff0c\u82e5\u6709\u4efb\u4f55\u610f\u898b\u6b61\u8fce\u7559\u8a00\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><span style=\"color: #687fff;\" class=\"stk-highlight\">CodingBar Python\u57fa\u790e\u73ed\u958b\u8dd1\u4e2d~\u6709\u8208\u8da3\u53ef\u4ee5\u9ede\u64ca\u9023\u7d50 <\/span><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%80%A0%E5%AD%97%E7%A8%8B%E5%BC%8F\"><\/span><span style=\"color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 36px; text-align: center; white-space: normal; background-color: rgb(255, 255, 255);\">\u9020\u5b57\u7a0b\u5f0f<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u76f4\u63a5\u9023TimeStamp<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"\u3010APCS\u89e3\u5bc6\u3011112\u5e74\u4e00\u6708APCS\u5be6\u4f5c\u984c\u89e3\u6790\uff1a\u7a0b\u5f0f\u8003\u8a66\u3001\u9020\u5b57\u7a0b\u5f0f\u3001\u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578\u3001\u6a5f\u5668\u51fa\u79df\" width=\"1290\" height=\"726\" src=\"https:\/\/www.youtube.com\/embed\/sgFaT7tsAtU?start=410&#038;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u984c\u76ee\u7c21\u8ff0\uff1a<br>\u9996\u5148\u6211\u5011\u77e5\u9053\u6703\u5148\u8f38\u5165 K\u3001Q\u3001R \u4e09\u7b46\u8cc7\u6599\uff0c\u5176\u4e2dK\u4ee3\u8868\u5b57\u4e32S\u7684\u9577\u5ea6\u3002<br>Q\u662f\u4ee3\u8868\u4e86\u5b57\u4e32\u4fee\u6539\u7684\u6b21\u6578\uff0cR\u662f\u4ee3\u8868\u524dR\u884c\u7684\u5b57\u4e32\u8981\u9032\u884c\u8f38\u51fa\uff0c\u4e5f\u5c31\u662f\u73fe\u5728\u7d05\u8272\u6846\u8d77\u4f86\u7684\u90e8\u5206\u3002\u7576R\u7b49\u65bc1\u6642\u8f38\u51fa\u7b2c\u4e00\u884c\uff0c\u7b49\u65bc2\u6642\u8f38\u51fa\u7b2c\u4e8c\u884c\uff0c\u4ee5\u6b64\u985e\u63a8\u3002\u90a3\u9019\u908a\u7d66\u4e00\u500b\u5f88\u7c21\u55ae\u7684\u7bc4\u4f8b\u8f38\u5165\uff0c\u8b93\u6211\u5011\u4f86\u89c0\u5bdf\u4e00\u4e0b\u9019\u6771\u897f\u662f\u5982\u4f55\u9032\u884c\u8cc7\u6599\u4ea4\u63db\u7684\u3002\u5c0d\u6b64\u4e0d\u719f\u6089\u7684\u540c\u5b78\uff0c\u53ef\u4ee5\u5b78\u7fd2\u9019\u6a23\u7684\u6280\u5de7\u5e6b\u52a9\u81ea\u5df1\u6574\u7406\u601d\u7dd2\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p2.gif?resize=1024%2C576&#038;ssl=1\" alt=\"APCS Python \u9020\u5b57\u7a0b\u5f0f\" class=\"wp-image-3893\" srcset=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p2.gif?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p2.gif?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p2.gif?resize=768%2C432&amp;ssl=1 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" data-recalc-dims=\"1\" \/><figcaption class=\"wp-element-caption\">\u9996\u5148\u6211\u5011\u89c0\u5bdf 4 1 3 2<br>\u5b83\u4ee3\u8868\u4e86A\u8981\u88ab\u4ea4\u63db\u5230\u7b2c\u56db\u500b\u683c\u5b50\uff0cP\u8981\u88ab\u4ea4\u63db\u5230\u7b2c\u4e00\u500b\u683c\u5b50\uff0cC\u8981\u88ab\u4ea4\u63db\u5230\u7b2c\u4e09\u500b\u683c\u5b50\uff0cS\u8981\u88ab\u4ea4\u63db\u5230\u7b2c\u4e8c\u500b\u683c\u5b50\uff0c\u4e5f\u5c31\u662f\u88ab\u4ea4\u63db\u4e00\u6b21\u5f8c\u6703\u8b8a\u6210PSCA\u3002\u4e5f\u5c31\u662f\u88ab\u4ea4\u63db\u4e00\u6b21\u5f8c\u6703\u8b8a\u6210PSCA\u9019\u6a23\u5b50\u7684\u72c0\u6cc1\uff0c\u90a3\u6211\u9019\u908a\u5927\u81f4\u4e0a\u4e5f\u5beb\u4e86\u4e00\u500b\u82e5\u4ee5list\u5f62\u5f0f\u8003\u91cf\u7684\u8a71\uff0c\u6b64\u5b57\u4e32\u6703\u662f\u5982\u4f55\u8b8a\u5316\u7684\u793a\u610f\u5716\u3002\u9019\u5f88\u91cd\u8981\uff0c\u7b49\u7b49\u5beb\u7a0b\u5f0f\u6703\u7528\u5230\uff0c\u5343\u842c\u4e0d\u8981\u5fd8\u8a18\u4e86\u3002\u5f8c\u9762\u7686\u4ee5\u76f8\u540c\u7684\u683c\u5f0f\u9032\u884c\u3002<\/figcaption><\/figure>\n\n\n\n<p>\u6709\u4e86\u4ee5\u4e0a\u7684\u6982\u5ff5\u5f8c\u6211\u5927\u6982\u4e0a\u4e00\u4e0b\u89e3\u984c\u6d41\u7a0b<br><strong>\u8f38\u5165\uff1a<\/strong><br><strong>1. \u6b63\u6574\u6578K\u3001Q\u3001R<\/strong><br><strong>2. \u5b57\u4e32S<\/strong><br><strong>3. Q\u884c\uff0c1~K\u4e0d\u91cd\u8907\u7684\u6578\u5b57 -&gt; nums<\/strong><br><strong>\u908f\u8f2f\uff1a<\/strong><br><strong>1. \u9700\u8981\u8a18\u9304\u65b0\u5b57\u4e32 -&gt; newS<\/strong><br><strong>2. \u900f\u904efor\u8ff4\u5708\u8b80\u53d6nums\uff0c\u5c07s\u5b57\u4e32\u5b58\u5165newS<\/strong><br><strong>3. \u9700\u8981\u7d00\u9304\u6bcf\u7a2e\u578b\u614b\u7684newS -&gt; sList<\/strong><br><strong>4. \u8abf\u6574sList\u683c\u5f0f\uff0c\u4f7f\u4e4b\u884c\u5217\u985b\u5012<\/strong><br><strong>\u8f38\u51fa\uff1a<\/strong><br><strong>1. \u900f\u904efor\u8ff4\u5708\u5c07\u7b2cR\u884c\u7684\u5b57\u6bcd\u9032\u884c\u8f38\u51fa\u3002<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: \u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~; toolbar: true; notranslate\" title=\"\u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~\">\nk,q,r = &#x5B;int(i) for i in input().split()]\ns = list(input())\nsList = &#x5B;]\nfor _ in range(q):\n    nums = &#x5B;int(i) for i in input().split()]\n    newS = &#x5B;&quot;&quot;]*k\n    for i in range(len(nums)):\n        newS&#x5B;nums&#x5B;i] - 1] = s&#x5B;i]\n    s = newS\n    sList.append(s)\nnewSList = list(zip(*sList))\nfor i in range(r):\n    print(&quot;&quot;.join(newSList&#x5B;i]),end=&quot;&quot;)\n<\/pre><\/div>\n\n\n<p>\u4ee5\u4e0a\u70ba\u89e3\u984c\u904e\u7a0b\uff0c\u82e5\u6709\u4efb\u4f55\u610f\u898b\u6b61\u8fce\u7559\u8a00\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%85%88%E5%8A%A0%E5%BE%8C%E4%B9%98%E8%88%87%E5%87%BD%E6%95%B8\"><\/span><span style=\"color: rgb(51, 51, 51); font-family: &quot;Helvetica Neue&quot;, Helvetica, Arial, sans-serif; font-size: 36px; text-align: center; white-space: normal; background-color: rgb(255, 255, 255);\">\u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u76f4\u63a5\u9023TimeStamp\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"\u3010APCS\u89e3\u5bc6\u3011112\u5e74\u4e00\u6708APCS\u5be6\u4f5c\u984c\u89e3\u6790\uff1a\u7a0b\u5f0f\u8003\u8a66\u3001\u9020\u5b57\u7a0b\u5f0f\u3001\u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578\u3001\u6a5f\u5668\u51fa\u79df\" width=\"1290\" height=\"726\" src=\"https:\/\/www.youtube.com\/embed\/sgFaT7tsAtU?start=918&#038;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u984c\u76ee\u7c21\u8ff0\uff1a<br>\u9996\u5148\u6211\u5011\u77e5\u9053\u6703\u5148\u8f38\u5165\u5b57\u4e32S\uff0c\u88e1\u9762\u53ea\u6703\u542b\u6709\u6578\u5b57\u3001+\u865f\u3001*\u4e58\u865f\u8ddff()<br>\u90a3\u9019\u4e00\u984c\u6709\u5f88\u591a\u7a2e\u4f5c\u6cd5\u8209\u51e1\u905e\u8ff4\u6216\u8005\u662fstack\uff0c\u90a3\u6211\u9019\u908a\u6703\u7528stack\u7684\u65b9\u5f0f\u4f86\u9032\u884c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p3.gif?resize=1024%2C576&#038;ssl=1\" alt=\"APCS Python \u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578-1\" class=\"wp-image-3894\" srcset=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p3.gif?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p3.gif?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p3.gif?resize=768%2C432&amp;ssl=1 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" data-recalc-dims=\"1\" \/><figcaption class=\"wp-element-caption\">\u90a3\u6211\u5011\u61c9\u8a72\u600e\u9ebc\u505a\u5462\uff1f\u9996\u5148\u6211\u5011\u5148\u4f86\u61c9\u4ed8\u6bd4\u8f03\u7c21\u55ae\u7684S2\u5427\uff01\u5728\u8b80\u53d6\u9019\u5806\u6771\u897f\u6642\uff0c\u6211\u5011\u53ef\u4ee5\u5148\u884c\u5ffd\u7565\u6389*\u865f\uff0c\u512a\u5148\u53bb\u7b97\u52a0\u865f\uff0c\u600e\u6a23\u5ffd\u7565\u6700\u65b9\u4fbf\u5462\uff1f\u7576\u7136\u5c31\u662f\u76f4\u63a5\u7528str.split()\u79fb\u9664\u56c9\uff01<br>\u63a5\u8457\u628a\u52a0\u865f\u8a08\u7b97\u5b8c\u7562\u518d\u628a\u4e58\u865f\u4e1f\u56de\u53bb\uff0c\u6700\u5f8c\u518d\u8a08\u7b97\u4e00\u6b21\u5c31\u53ef\u4ee5\u5f97\u5230\u7b54\u6848\u56c9~<br><br><\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p3-2.gif?resize=1024%2C576&#038;ssl=1\" alt=\"APCS Python \u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578-2\n\" class=\"wp-image-3900\" srcset=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p3-2.gif?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p3-2.gif?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p3-2.gif?resize=768%2C432&amp;ssl=1 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" data-recalc-dims=\"1\" \/><figcaption class=\"wp-element-caption\">\u63a5\u8457\u5c31\u8981\u4f86\u770b\u6bd4\u8f03\u8907\u96dc\u7684\uff0c\u6211\u9019\u908a\u5148\u9732\u500b\u7bad\u982d\u7d66\u5927\u5bb6\u770b\uff0c\u65e2\u7136\u9019\u908a\u8981\u7528stack\u7684\u505a\u6cd5\uff0c\u6709\u6c92\u6709\u60f3\u5230\u4e00\u500b\u5f88\u7d93\u5178\u7684\u984c\u76ee\u5462\uff1f\u6c92\u932f\u5c31\u662f\u914d\u5c0d\u62ec\u5f27\u7684\u90a3\u4e00\u984c\uff0c\u6211\u5011\u8981\u60f3\u8fa6\u6cd5\u5e6b\u5979\u914d\u5c0d\u51fa\u4e00\u5c0d\u62ec\u5f27\u51fa\u4f86\uff01<br><br>\u7576\u6211\u627e\u5230f\u6642\uff0c\u5176\u5be6\u5c31\u4ee3\u8868\u4ed6\u53f3\u908a\u4e00\u5b9a\u6703\u6709\u5de6\u62ec\u5f27\u8ddf\u53f3\u62ec\u5f27\u3002\u4f46\u9019\u908a\u8981\u6ce8\u610f\u5594\uff0cf\u88e1\u9762\u53ef\u80fd\u518d\u5305\u8457\u4e00\u5c64f\uff0c\u6240\u4ee5\u6211\u5728\u67e5\u627e\u7684\u6642\u5019\uff0c\u6703\u76f4\u63a5\u67e5\u5230\u6700\u6df1\u5c64\u7684f\uff0c\u7136\u5f8c\u958b\u59cb\u8a08\u7b97\u62ec\u5f27\u88e1\u9762\u7684\u6578\u5b57\u3002\u90a3\u7531\u65bc\u9019\u908a\u7684\u62ec\u5f27\u5fc5\u5b9a\u6703\u6210\u5c0d\uff0c\u6240\u4ee5\u4e0d\u7528\u64d4\u5fc3\u5f80\u53f3\u627e\u627e\u4e0d\u5230\u53f3\u62ec\u5f27\uff0c\u76f4\u63a5\u628a\u62ec\u5f27\u88e1\u9762\u7684\u6578\u5b57\u6293\u51fa\u4f86\u904b\u7b97\uff0c\u6240\u4ee5f(3,2)\u5c31\u8b8a\u62101\u4e86\u3002<br><br>\u63a5\u8457\u56de\u5230\u525b\u525b\u4e5f\u6709\u78b0\u5230f\u7684\u5730\u65b9\uff0c\u7136\u5f8c\u5f80\u53f3\u627e\u8207\u4ed6\u6210\u5c0d\u7684\u53f3\u62ec\u5f27\uff0c\u4f46\u9019\u908a\u5728\u904b\u7b97\u6642\u53ef\u80fd\u6703\u51fa\u73fe\u5c0f\u554f\u984c\uff0c<br>\u90a3\u5c31\u662f\u9084\u6709\u52a0\u865f\u8207\u4e58\u865f\u6c92\u6709\u8a08\u7b97\uff0c\u56e0\u6b64\u6211\u4e0d\u80fd\u5920\u76f4\u63a5\u6c42f()\uff0c\u6240\u4ee5\u5176\u5be6\u9019\u908a\u5728\u904b\u7b97\u524d\uff0c\u8981\u5148\u628a\u88ab\u9017\u9ede\u5206\u9694\u7684\u6578\u5b57\u5011\u9032\u884c\u5224\u65b7\uff0c\u770b\u662f\u5426\u9700\u8981\u8a08\u7b97\u4e58\u865f\u6216\u8005\u662f\u52a0\u865f\u3002\u6240\u4ee5\u5c31\u8b8a\u6210\u4e86f(8,9,1)\uff0c\u90a3f(8,9,1)\u6703\u518d\u88ab\u8a08\u7b978\uff0c\u6700\u5f8c\u5c31\u53ef\u4ee5\u76f4\u63a5\u6c42\u51fa\u7b54\u6848\u56c9\uff01\u4f46\u5225\u5fd8\u8a18+\u865f\u512a\u5148\u65bc\u4e58\u865f\u5537\uff01<\/figcaption><\/figure>\n\n\n\n<p>\u6709\u4e86\u4ee5\u4e0a\u7684\u6982\u5ff5\u5f8c\u6211\u5927\u6982\u4e0a\u4e00\u4e0b\u89e3\u984c\u6d41\u7a0b<br><strong>\u8f38\u5165\uff1a<\/strong><br><strong>1. s\u5b57\u4e32<\/strong><br><strong>\u908f\u8f2f\uff1a<\/strong><br><strong>1. s\u5b57\u4e32\u4e0d\u542bf\u7684\u72c0\u6cc1 -&gt; nof()<\/strong><br><strong>2. s\u5b57\u4e32\u542bf\u7684\u72c0\u6cc1 -&gt; \u5c0b\u627e\u6210\u5c0d\u7684\u62ec\u5f27\u5011(\u76f4\u63a5\u627e\u6700\u5167\u5c64\u7684)<\/strong><br><strong>3. \u627e\u5230\u6210\u5c0d\u62ec\u5f27 -&gt; \u9017\u9ede\u8207\u9017\u9ede\u9593\u7684\u662f\u5426\u542b&#8221;+&#8221;\u6216&#8221;*&#8221;<\/strong><br><strong>&nbsp;&nbsp;&nbsp; 3-1.\u662f -&gt; nof()<\/strong><br><strong>&nbsp;&nbsp;&nbsp; 3-2.\u4e0d\u662f -&gt; f()<\/strong><br><strong>4. \u8a08\u7b97\u5b8c\u7684\u7d50\u679c\u53d6\u4ee3\u539f\u672c\u4f4d\u7f6e\u4e0a\u7684\u6587\u5b57\uff0c\u65b9\u4fbf\u4e0b\u6b21\u904b\u7b97<\/strong><br><strong>5. 2~4\u5faa\u74b0<\/strong><br><strong>\u8f38\u51fa\uff1a<\/strong><br><strong>1. \u8f38\u51fa\u8a08\u7b97\u7d50\u679c<\/strong><\/p>\n\n\n\n<p>\u4ee5\u4e0b\u6709\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\uff0c\u9996\u5148\u5982\u679c\u4f60\u53ea\u898130%\u7684\u8a71<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: \u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~; toolbar: true; notranslate\" title=\"\u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~\">\ndef noF(s):\n    temp = s.split(&#039;*&#039;)\n    for i in range(len(temp)):\n        temp&#x5B;i] = eval(temp&#x5B;i])\n    result = &quot;*&quot;.join(map(str,temp))\n    return eval(result)\ns = input()\nif &quot;f&quot; not in s:\n    ans = noF(s)\n    print(ans)\n<\/pre><\/div>\n\n\n<p>\u5982\u679c\u4f60\u60f3\u8981\u5168\u5c0d\u7684\u8a71~<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: \u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~; toolbar: true; notranslate\" title=\"\u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~\">\ndef noF(s):\n    temp = s.split(&#039;*&#039;)\n    for i in range(len(temp)):\n        temp&#x5B;i] = eval(temp&#x5B;i])\n    result = &quot;*&quot;.join(map(str,temp))\n    return eval(result)\ndef f(*args):\n    a,b = max(args),min(args)\n    return a-b\ns = input()\nif &quot;f&quot; not in s:\n    ans = noF(s)\n    print(ans)\nelse:\n    leftPar = &#x5B;i for i,v in enumerate(s) if v == &#039;f&#039;]\n    while leftPar:\n        leftIndex = leftPar.pop()\n        i = leftIndex\n        while 1:\n            if s&#x5B;i] == &quot;)&quot;:\n                rightIndex = i\n                break\n            i+=1        \n        temp = s&#x5B;leftIndex:rightIndex+1].split(&#039;,&#039;)\n        for i in range(len(temp)):\n            if &#039;f(&#039; in temp&#x5B;i] and &#039;)&#039; in temp&#x5B;i]:\n                temp&#x5B;i] = str(eval(temp&#x5B;i]))\n            elif &quot;+&quot; in temp&#x5B;i] or &quot;*&quot; in temp&#x5B;i]:\n                if &#039;f(&#039; in temp&#x5B;i]:\n                    temp&#x5B;i] = &#039;f(&#039; + str(noF(temp&#x5B;i]&#x5B;2:]))\n                elif &#039;)&#039; in temp&#x5B;i]:\n                    temp&#x5B;i] = str(noF(temp&#x5B;i]&#x5B;:-1])) + &#039;)&#039;\n                else:\n                    temp&#x5B;i] = str(noF(temp&#x5B;i]))\n        temp = &quot;,&quot;.join(temp)\n        if &#039;f&#039; in temp:\n            temp = str(eval(temp))\n        s = s&#x5B;:leftIndex] + temp + s&#x5B;rightIndex+1:]\n    ans = noF(s)\n    print(ans)\n<\/pre><\/div>\n\n\n<p>\u4ee5\u4e0a\u70ba\u89e3\u984c\u904e\u7a0b\uff0c\u82e5\u6709\u4efb\u4f55\u610f\u898b\u6b61\u8fce\u7559\u8a00\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%A9%9F%E5%99%A8%E5%87%BA%E7%A7%9F\"><\/span>\u6a5f\u5668\u51fa\u79df<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u76f4\u63a5\u9023TimeStamp\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"\u3010APCS\u89e3\u5bc6\u3011112\u5e74\u4e00\u6708APCS\u5be6\u4f5c\u984c\u89e3\u6790\uff1a\u7a0b\u5f0f\u8003\u8a66\u3001\u9020\u5b57\u7a0b\u5f0f\u3001\u5148\u52a0\u5f8c\u4e58\u8207\u51fd\u6578\u3001\u6a5f\u5668\u51fa\u79df\" width=\"1290\" height=\"726\" src=\"https:\/\/www.youtube.com\/embed\/sgFaT7tsAtU?start=1590&#038;feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>\u984c\u76ee\u7c21\u8ff0\uff1a<br>\u76ee\u6709\u63d0\u5230\u6703\u6709K\u53f0\u6a5f\u5668\u4ee5\u53caN\u500b\u6d3b\u52d5\uff0c\u6bcf\u53f0\u6a5f\u5668\u5728\u4e00\u500b\u6642\u9593\u9ede\u53ea\u80fd\u53c3\u8207\u4e00\u500b\u6d3b\u52d5\uff0c\u6c42\u53ef\u4ee5\u53c3\u8207\u7684\u6700\u5927\u6d3b\u52d5\u6578\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p4.gif?resize=1024%2C576&#038;ssl=1\" alt=\"APCS Python \u6a5f\u5668\u51fa\u79df\" class=\"wp-image-3903\" srcset=\"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p4.gif?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p4.gif?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/11201p4.gif?resize=768%2C432&amp;ssl=1 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" data-recalc-dims=\"1\" \/><figcaption class=\"wp-element-caption\">\u9996\u5148\u984c\u76ee\u6709\u63d0\u5230\u6703\u6709K\u53f0\u6a5f\u5668\uff0c\u7136\u5f8cN\u500b\u6d3b\u52d5\u3002<br>\u56e0\u6b64\u6211\u5148\u756b\u9019\u6a23\u7684\u5716\u51fa\u4f86\uff0cK\u90a3\u908a\u7684-1\u4ee3\u8868\u6a5f\u5668\u672a\u88ab\u4f7f\u7528\uff0cN\u90a3\u908a\u7684\u6578\u5b57\u4ee3\u8868\u6d3b\u52d5\u6642\u9593<br>\u9996\u5148\u9047\u5230\u6d3b\u52d5[0,3]\uff0c\u5148\u628a\u4e00\u53f0\u6a5f\u5668\u7d00\u9304\u7d50\u675f\u6642\u9593\uff0c\u63a5\u8457\u9047\u5230\u6d3b\u52d5[1,4]\uff0c\u7531\u65bc\u53e6\u5916\u4e00\u53f0\u6a5f\u5668\u4f7f\u7528\u4e2d\uff0c\u56e0\u6b64\u628a\u5b83\u8b93\u7d66\u53e6\u5916\u4e00\u53f0\u6a5f\u5668\u4f7f\u7528\uff0c\u6211\u9019\u908a\u5077\u5077switch\u6a5f\u5668\u7684\u6392\u5217\u9806\u5e8f\uff0c\u9019\u7b49\u7b49\u5beb\u7a0b\u5f0f\u6642\u6703\u7528\u5230\u76f8\u540c\u6982\u5ff5\u3002\u63a5\u8457\u9047\u5230\u6d3b\u52d5[5,6]\uff0c\u9019\u908a\u5c31\u8981\u6ce8\u610f\u4e86\uff0c\u6211\u5011\u61c9\u8a72\u9078\u64c7\u7d50\u675f\u6642\u9593\u70ba4\u7684\u6a5f\u5668\uff0c\u800c\u4e0d\u80fd\u9078\u64c7\u70ba3\u7684\uff0c\u8981\u4e0d\u7136\u4e0b\u500b\u6d3b\u52d5\u6642\u6703\u76f4\u63a5\u5c11\u4e00\u53f0\u6a5f\u5668\u4f7f\u7528\uff0c\u9019\u908a\u8981\u597d\u597d\u601d\u8003\u4e00\u4e0b\uff0c\u8981\u600e\u9ebc\u7528\u7a0b\u5f0f\u8655\u7406\u9019\u4ef6\u4e8b\u60c5\u3002\u63a5\u8457\u9047\u5230\u6d3b\u52d5[4,6]<br>\u4f7f\u7528\u53e6\u5916\u4e00\u53f0\u6a5f\u5668\u3002\u6700\u5f8c\u5c31\u662f7\u3002\u56e0\u6b64\uff0c\u6b64\u7bc4\u4f8b\u53ef\u4ee5\u4e94\u500b\u6d3b\u52d5\u90fd\u8dd1\u5230\u3002<\/figcaption><\/figure>\n\n\n\n<p>\u6709\u4e86\u4ee5\u4e0a\u7684\u6982\u5ff5\u5f8c\u6211\u5927\u6982\u4e0a\u4e00\u4e0b\u89e3\u984c\u6d41\u7a0b<br><strong>\u8f38\u5165\uff1a<\/strong><br><strong>1. N\u500b\u6d3b\u52d5\u3001K\u53f0\u6a5f\u5668<\/strong><br><strong>2. \u7b2c\u4e8c\u884c\u70ba\u958b\u59cb\u6642\u9593\u3001\u7b2c\u4e09\u884c\u70ba\u7d50\u675f\u6642\u9593<\/strong><br><strong>\u908f\u8f2f\uff1a<\/strong><br><strong>1. \u5408\u4f75\u958b\u59cb\u8207\u7d50\u675f\u6642\u9593<\/strong><br><strong>2. \u512a\u5148\u5c0b\u627e\u6700\u5148\u7d50\u675f\u7684\u6642\u9593<\/strong><br><strong>3. \u628a\u6a5f\u5668\u64cd\u6b7b\u7684\u7cbe\u795e -&gt; \u5728\u53ef\u4ee5\u7684\u6a5f\u5668\u4e2d\u6c38\u9060\u627e\u6700\u665a\u7d50\u675f\u7684\u6a5f\u5668<\/strong><br><strong>\u8f38\u51fa\uff1a<\/strong><br><strong>\u5c31\u8f38\u51fa\u53ef\u4ee5\u53c3\u8207\u7684\u6d3b\u52d5\u6578\u91cf<\/strong><\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f40%\u7684\u7a0b\u5f0f\u78bc~<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: \u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~; toolbar: true; notranslate\" title=\"\u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~\">\nN,K = &#x5B;int(i) for i in input().split()]\nstart = &#x5B;int(i) for i in input().split()]\nend = &#x5B;int(i) for i in input().split()]\ntimeS = &#x5B;&#x5B;start&#x5B;i],end&#x5B;i]] for i in range(N)]\ntimeS.sort(key = lambda x:(x&#x5B;1]))\nendTime = -1\nans = 0\nfor start,end in timeS:\n    if start &gt; endTime:\n        ans+=1\n        endTime = end\nprint(ans)\n<\/pre><\/div>\n\n\n<p>\u4ee5\u4e0b\u662f100%\u7684\u7a0b\u5f0f\u78bc~<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: \u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~; toolbar: true; notranslate\" title=\"\u88e1\u9762\u5b58\u5728\u53ef\u611b\u7684\u7a0b\u5f0f\u78bc\u5537~\">\n# \u6d41\u7a0b\uff1a\n# \u8f38\u5165\uff1a \nimport bisect\nN,K = &#x5B;int(i) for i in input().split()]# 1. N\u500b\u6d3b\u52d5\u3001K\u53f0\u6a5f\u5668\nstart = &#x5B;int(i) for i in input().split()]# 2. \u7b2c\u4e8c\u884c\u70ba\u958b\u59cb\u6642\u9593\u3001\u7b2c\u4e09\u884c\u70ba\u7d50\u675f\u6642\u9593\nend = &#x5B;int(i) for i in input().split()]\ntimeS = &#x5B;&#x5B;start&#x5B;i],end&#x5B;i]] for i in range(N)]# 1. \u5408\u4f75\u958b\u59cb\u8207\u7d50\u675f\u6642\u9593\ntimeS.sort(key = lambda x:(x&#x5B;1]))\nendTime = &#x5B;-1]*K\nans = 0\nfor start,end in timeS:\n    if min(endTime)&gt;= start:#\u5982\u679c\u6c92\u6709\u9592\u7f6e\u7684\u6a5f\u5668\n        continue\n    index = bisect.bisect_left(endTime,start)-1\n    del endTime&#x5B;index]\n    endTime.append(end)# 3. \u628a\u6a5f\u5668\u64cd\u6b7b\u7684\u7cbe\u795e -&gt; \u5728\u53ef\u4ee5\u7684\u6a5f\u5668\u4e2d\u6c38\u9060\u627e\u6700\u665a\u7d50\u675f\u7684\u6a5f\u5668\n    # 2. \u512a\u5148\u5c0b\u627e\u6700\u5148\u7d50\u675f\u7684\u6642\u9593\n    ans+=1\nprint(ans)\n<\/pre><\/div>\n\n\n<p>\u4ee5\u4e0a\u70ba\u89e3\u984c\u904e\u7a0b\uff0c\u82e5\u6709\u4efb\u4f55\u610f\u898b\u6b61\u8fce\u7559\u8a00\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6b21\u984c\u76ee\u6709\u9ede\u4ee4\u4eba\u611f\u5230\u610f\u5916\uff0c\u76f8\u8f03\u65bc\u4e4b\u524d\u7684\u984c\u76ee\u8003\u7684\u89c0\u5ff5\u6709\u9ede\u7565\u70ba\u4e0d\u540c\u3002<br \/>\n\u7b2c\u4e00\u984c\u662f\u70ba\u8fed\u4ee3\u7684\u57fa\u672c\u984c\uff0c\u53ea\u9808\u770b\u6e05\u984c\u76ee\u5373\u53ef\u7c21\u55ae\u5730\u5229\u7528\u8ff4\u5708\u8a08\u7b97\u51fa\u7b54\u6848\u3002<br \/>\n\u7b2c\u4e8c\u984c\u662f\u96d6\u7136\u662f\u5b57\u4e32\u8655\u7406\uff0c\u4f46\u500b\u4eba\u8a8d\u70ba\u6bd4\u8f03\u504f\u5411\u77e9\u9663\uff0c\u5229\u7528\u77e9\u9663\u53ef\u4ee5\u5feb\u901f\u5730\u89e3\u51fa\u6b64\u984c\u7b54\u6848\u3002<br \/>\n\u7b2c\u4e09\u984c\u8003\u9a57\u4e5f\u662f\u5b57\u4e32\u8655\u7406\uff0c\u4f46\u7d50\u5408\u4e86\u905e\u8ff4\u6216\u8005\u662fstack\u7684\u6982\u5ff5\uff0c\u4f46\u5c31\u7b97\u662f\u4e0d\u719f\u6089\u905e\u8ff4\u4ee5\u53castack\u4f9d\u7136\u53ef\u4ee5\u4f7f\u7528\u666e\u901a\u65b9\u6cd5\u7372\u5f9730\u5206\uff0c\u7b97\u662f\u826f\u5fc3\u984c\u3002<br \/>\n\u7b2c\u56db\u984c\u5c31\u662f\u4f7f\u7528\u8caa\u5a6a\u6f14\u7b97\u6cd5\uff0c\u53ea\u8981\u6709\u60f3\u5230\u5169\u500b\u89e3\u984c\u91cd\u9ede\uff1a&#8230;..<\/p>\n","protected":false},"author":12,"featured_media":3904,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[1],"tags":[39,53,75,203,207,29,9,20,204,25,205],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/codingbar.ai\/content\/wp-content\/uploads\/2023\/01\/SL-103020-37400-24-2500x1429.jpg?fit=2500%2C1429&ssl=1","_links":{"self":[{"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/posts\/3887"}],"collection":[{"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/comments?post=3887"}],"version-history":[{"count":6,"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/posts\/3887\/revisions"}],"predecessor-version":[{"id":3935,"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/posts\/3887\/revisions\/3935"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/media\/3904"}],"wp:attachment":[{"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/media?parent=3887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/categories?post=3887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codingbar.ai\/content\/wp-json\/wp\/v2\/tags?post=3887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}