{"id":102,"date":"2025-01-11T23:29:40","date_gmt":"2025-01-11T15:29:40","guid":{"rendered":"http:\/\/150.230.63.147\/blog\/?p=102"},"modified":"2025-01-11T23:29:40","modified_gmt":"2025-01-11T15:29:40","slug":"a-cubes-sorting-%e8%a7%a3%e6%9e%90%e6%80%9d%e7%b6%ad","status":"publish","type":"post","link":"https:\/\/blog.seekrealthing.net\/blog\/?p=102","title":{"rendered":"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad)"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><h1>Codeforce 1420 A. Cubes Sorting \u89e3\u6790(\u601d\u7dad)<\/h1>\n<p>\u4eca\u5929\u6211\u5011\u4f86\u770b\u770bCF1420<br>\n<a href=\"https:\/\/codeforces.com\/problemset\/problem\/1420\/A\">\u984c\u76ee\u9023\u7d50<\/a><\/p>\n<blockquote>\n<p><strong>\u984c\u76ee<\/strong><br>\n\u7d66\u4e00\u500b\u6578\u5217$a$\uff0c\u6c42\u80fd\u4e0d\u80fd\u5728\u4e0d\u8d85\u904e$\\frac{n(n-1)}{2}-1$\u6b21\u76f8\u9130\u5143\u7d20\u7684\u8abf\u63db\u4e0b\uff0c\u5f97\u5230\u905e\u589e\u6578\u5217\u3002<\/p>\n<\/blockquote>\n<h3>\u524d\u8a00<\/h3>\n<p>b<\/p>\n<h3>\u60f3\u6cd5<\/h3>\n<p>\u6ce8\u610f\u5230\uff0c\u9019\u662f$A$\u984c\uff0c\u6240\u4ee5\u4e00\u5b9a\u4e0d\u6703\u8981\u4f60\u69cb\u9020\u592a\u96e3\u7684\u6771\u897f\u3002<br>\n\u6ce8\u610f\u5230$\\frac{n(n-1)}{2}-1$\u5f88\u53ef\u7591\uff0c\u9019\u4e00\u5b9a\u4ee3\u8868\u67d0\u500b\u6771\u897f\u3002<br>\n\u89c0\u5bdf\u5230\u6211\u5011\u81f3\u591a\u81f3\u591a\uff0c\u5c31\u662f\u9700\u8981$\\frac{n(n-1)}{2}$\u6b65\u4f86\u8abf\u63db\u6578\u5217\uff0c\u56e0\u70ba\u5982\u679c\u76ee\u524d\u6578\u5217\u6578\u5b57\u662f<strong>\u5168\u90e8\u76f8\u7570<\/strong>\u4e14\u662f<strong>\u905e\u6e1b<\/strong>\uff0c\u90a3\u9ebc\u6162\u6162\u628a\u6bcf\u500b\u6578\u5b57\u653e\u5230\u4ed6\u61c9\u6709\u7684\u4f4d\u7f6e\uff0c\u9700\u8981$(n-1)+(n-2)+\u2026+1=\\frac{n(n-1)}{2}$\u6b65\u3002<br>\n\u56e0\u6b64\u6211\u5011\u53ea\u9700\u8981\u770b\u770b\u6578\u5217\u662f\u5426\u662f<strong>\u5168\u90e8\u76f8\u7570<\/strong>\u4e14\u662f<strong>\u905e\u6e1b<\/strong>\uff0c\u5982\u679c\u662f\uff0c\u90a3\u9ebc\u7121\u6cd5\u9054\u6210\uff1b\u5982\u679c\u4e0d\u662f\uff0c\u90a3\u9ebc\u5c31\u53ef\u4ee5\u3002<\/p>\n<h3>\u7a0b\u5f0f\u78bc:<\/h3>\n<pre><code class=\"language-cpp=\">const int _n=5e4+10;  \nint t,n,m,a[_n],aa[_n];  \nmain(void) {ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  \n  cin&gt;&gt;t;while(t--){  \n    cin&gt;&gt;n;rep(i,0,n){cin&gt;&gt;a[i];aa[i]=a[i];} sort(aa,aa+n,greater&lt;int&gt;());  \n    int prev=-1;rep(i,0,n){  \n      if(a[i]!=aa[i] or aa[i]==prev){cout&lt;&lt;&quot;YES\\n&quot;;goto A;}  \n      prev=aa[i];  \n    }  \n    cout&lt;&lt;&quot;NO\\n&quot;;  \n    A:;  \n  }  \n  return 0;  \n}  \n<\/code><\/pre>\n<p>\u6a19\u982d\u3001\u6a21\u677f\u8acb\u9edeSubmission\u770b<br>\n<a href=\"https:\/\/codeforces.com\/contest\/1420\/submission\/93659865\">Submission<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[3],"tags":[10,9,8],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-ojcode","tag-codeforce","tag-ojcode","tag-8"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A. Cubes Sorting \u89e3\u6790(\u601d\u7dad) - Logic Formatting<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.seekrealthing.net\/blog\/?p=102\" \/>\n<meta property=\"og:locale\" content=\"zh_TW\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad) - Logic Formatting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.seekrealthing.net\/blog\/?p=102\" \/>\n<meta property=\"og:site_name\" content=\"Logic Formatting\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-11T15:29:40+00:00\" \/>\n<meta name=\"author\" content=\"jeff\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005:\" \/>\n\t<meta name=\"twitter:data1\" content=\"jeff\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9810\u4f30\u95b1\u8b80\u6642\u9593\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\u9418\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=102#article\",\"isPartOf\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=102\"},\"author\":{\"name\":\"jeff\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/233e80a0fee3d4706f067f2e88c0b454\"},\"headline\":\"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad)\",\"datePublished\":\"2025-01-11T15:29:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=102\"},\"wordCount\":29,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#organization\"},\"keywords\":[\"codeforce\",\"ojcode\",\"\u601d\u7dad\"],\"articleSection\":[\"ojcode\"],\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blog.seekrealthing.net\/blog\/?p=102#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=102\",\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=102\",\"name\":\"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad) - Logic Formatting\",\"isPartOf\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#website\"},\"datePublished\":\"2025-01-11T15:29:40+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=102#breadcrumb\"},\"inLanguage\":\"zh-TW\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog.seekrealthing.net\/blog\/?p=102\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/?p=102#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9801\",\"item\":\"https:\/\/blog.seekrealthing.net\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#website\",\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/\",\"name\":\"Logic Formatting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog.seekrealthing.net\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-TW\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#organization\",\"name\":\"Logic Formatting\",\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/wp-content\/uploads\/2025\/02\/android-chrome-512x512-1.png\",\"contentUrl\":\"https:\/\/blog.seekrealthing.net\/blog\/wp-content\/uploads\/2025\/02\/android-chrome-512x512-1.png\",\"width\":512,\"height\":512,\"caption\":\"Logic Formatting\"},\"image\":{\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/233e80a0fee3d4706f067f2e88c0b454\",\"name\":\"jeff\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-TW\",\"@id\":\"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f9b571b28c252728386f0002b35d9cb9a9028f740b0f9ca5ad678e7eb21c4857?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f9b571b28c252728386f0002b35d9cb9a9028f740b0f9ca5ad678e7eb21c4857?s=96&d=mm&r=g\",\"caption\":\"jeff\"},\"sameAs\":[\"http:\/\/150.230.63.147\/blog\"],\"url\":\"https:\/\/blog.seekrealthing.net\/blog\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad) - Logic Formatting","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.seekrealthing.net\/blog\/?p=102","og_locale":"zh_TW","og_type":"article","og_title":"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad) - Logic Formatting","og_url":"https:\/\/blog.seekrealthing.net\/blog\/?p=102","og_site_name":"Logic Formatting","article_published_time":"2025-01-11T15:29:40+00:00","author":"jeff","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005:":"jeff","\u9810\u4f30\u95b1\u8b80\u6642\u9593":"1 \u5206\u9418"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=102#article","isPartOf":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=102"},"author":{"name":"jeff","@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/233e80a0fee3d4706f067f2e88c0b454"},"headline":"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad)","datePublished":"2025-01-11T15:29:40+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=102"},"wordCount":29,"commentCount":0,"publisher":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/#organization"},"keywords":["codeforce","ojcode","\u601d\u7dad"],"articleSection":["ojcode"],"inLanguage":"zh-TW","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.seekrealthing.net\/blog\/?p=102#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=102","url":"https:\/\/blog.seekrealthing.net\/blog\/?p=102","name":"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad) - Logic Formatting","isPartOf":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/#website"},"datePublished":"2025-01-11T15:29:40+00:00","breadcrumb":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=102#breadcrumb"},"inLanguage":"zh-TW","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.seekrealthing.net\/blog\/?p=102"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.seekrealthing.net\/blog\/?p=102#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9801","item":"https:\/\/blog.seekrealthing.net\/blog"},{"@type":"ListItem","position":2,"name":"A. Cubes Sorting \u89e3\u6790(\u601d\u7dad)"}]},{"@type":"WebSite","@id":"https:\/\/blog.seekrealthing.net\/blog\/#website","url":"https:\/\/blog.seekrealthing.net\/blog\/","name":"Logic Formatting","description":"","publisher":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.seekrealthing.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-TW"},{"@type":"Organization","@id":"https:\/\/blog.seekrealthing.net\/blog\/#organization","name":"Logic Formatting","url":"https:\/\/blog.seekrealthing.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/blog.seekrealthing.net\/blog\/wp-content\/uploads\/2025\/02\/android-chrome-512x512-1.png","contentUrl":"https:\/\/blog.seekrealthing.net\/blog\/wp-content\/uploads\/2025\/02\/android-chrome-512x512-1.png","width":512,"height":512,"caption":"Logic Formatting"},"image":{"@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/233e80a0fee3d4706f067f2e88c0b454","name":"jeff","image":{"@type":"ImageObject","inLanguage":"zh-TW","@id":"https:\/\/blog.seekrealthing.net\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f9b571b28c252728386f0002b35d9cb9a9028f740b0f9ca5ad678e7eb21c4857?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f9b571b28c252728386f0002b35d9cb9a9028f740b0f9ca5ad678e7eb21c4857?s=96&d=mm&r=g","caption":"jeff"},"sameAs":["http:\/\/150.230.63.147\/blog"],"url":"https:\/\/blog.seekrealthing.net\/blog\/?author=1"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102"}],"version-history":[{"count":1,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions\/103"}],"wp:attachment":[{"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.seekrealthing.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}