{"id":1916,"date":"2026-10-03T12:00:00","date_gmt":"2026-10-03T12:00:00","guid":{"rendered":"https:\/\/accelthinking.com\/?p=1916"},"modified":"2026-10-10T03:29:08","modified_gmt":"2026-10-10T03:29:08","slug":"ccc-2023-s2-symmetric-mountains-solution-analysis","status":"publish","type":"post","link":"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/","title":{"rendered":"CCC 2023 S2 Symmetric Mountains Solution: Center Expansion for Minimum Asymmetry at Every Length"},"content":{"rendered":"<style>\nhtml,body,#page{background:#f8fafc!important}.site-header,.site-footer,#masthead,#colophon,.entry-header,.post-navigation,.comments-area{display:none!important}.entry-title{display:none!important}.site-content .ast-container{max-width:100%!important;padding:0!important}.entry-content{margin:0!important;line-height:0!important}.site-content,#content,#primary,#main,.ast-plain-container #primary{margin:0!important;padding:0!important;background:#f8fafc}.ast-article-single{padding:0!important}\n.ati-page,.ati-page *{box-sizing:border-box}.entry-content>.ati-page,.ati-page{display:flex!important;flex-direction:column!important;width:100%!important;max-width:none!important;margin-left:0!important;margin-right:0!important;font-family:Inter,Arial,sans-serif;color:#0f172a;background:#f8fafc;font-size:0;line-height:0}.ati-page>p,.ati-page main>p,.ati-footer>p{display:none!important;margin:0!important}.ati-page a{text-decoration:none;color:inherit}.ati-page svg{display:block}.ati-top,.ati-page main,.ati-footer{font-size:16px;line-height:1.5}\n.ati-top{position:relative;z-index:2;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;min-height:76px;padding:0 clamp(22px,6vw,116px);color:#fff;background:#050505;border-bottom:1px solid rgba(255,255,255,.08)}.ati-top>p{display:contents!important}.ati-top br,.ati-nav br{display:none!important}.ati-brand{display:inline-flex;align-items:center;width:max-content;color:#ffc400!important}.ati-logo img{display:block;width:auto;height:38px;max-width:min(260px,42vw);object-fit:contain}.ati-nav{display:flex;gap:clamp(20px,3vw,44px);align-items:center;justify-content:center;font-size:15px;font-weight:600}.ati-nav a{position:relative;padding:28px 0 24px;color:rgba(255,255,255,.86)!important}.ati-nav a:hover,.ati-nav a.active{color:#ffc400!important}.ati-nav a:after{position:absolute;right:0;bottom:19px;left:0;height:2px;content:\"\";background:#ffc400;transform:scaleX(0);transition:transform 160ms ease}.ati-nav a:hover:after,.ati-nav a.active:after{transform:scaleX(1)}.ati-header-cta{justify-self:end;display:inline-flex;align-items:center;justify-content:center;min-height:42px;padding:0 20px;color:#050505!important;background:#ffc400;border-radius:8px;font-size:14px;font-weight:800}\n.ati-page{--hero-pattern:radial-gradient(circle at 82% 24%,rgba(255,196,0,.18) 0 2px,transparent 3px),linear-gradient(135deg,rgba(255,255,255,.07) 1px,transparent 1px);--hero-pattern-size:90px 90px,38px 38px;--hero-pattern-opacity:.55}.ati-solutions{--hero-pattern:radial-gradient(circle at 25px 25px,rgba(255,196,0,.2) 0 2px,transparent 3px),linear-gradient(90deg,rgba(255,196,0,.09) 1px,transparent 1px),linear-gradient(0deg,rgba(255,255,255,.06) 1px,transparent 1px);--hero-pattern-size:96px 96px,96px 96px,96px 96px}.ati-cp-academy{--hero-pattern:radial-gradient(circle at 20px 20px,rgba(255,196,0,.26) 0 3px,transparent 4px),radial-gradient(circle at 74px 58px,rgba(20,184,166,.18) 0 2px,transparent 3px),linear-gradient(135deg,transparent 46%,rgba(255,196,0,.11) 47% 48%,transparent 49%);--hero-pattern-size:112px 112px,112px 112px,56px 56px}.ati-it-consulting{--hero-pattern:linear-gradient(90deg,transparent 0 28px,rgba(20,184,166,.14) 29px 30px,transparent 31px 72px),linear-gradient(0deg,transparent 0 28px,rgba(255,196,0,.1) 29px 30px,transparent 31px 72px),radial-gradient(circle at 30px 30px,rgba(20,184,166,.22) 0 2px,transparent 3px);--hero-pattern-size:72px 72px,72px 72px,72px 72px}.ati-about-page{--hero-pattern:linear-gradient(135deg,rgba(255,196,0,.12) 0 2px,transparent 2px 28px),radial-gradient(circle at 85% 28%,rgba(255,255,255,.12) 0 2px,transparent 3px);--hero-pattern-size:42px 42px,96px 96px}.ati-contact{--hero-pattern:radial-gradient(circle at 78% 44%,transparent 0 34px,rgba(255,196,0,.14) 35px 36px,transparent 37px 70px,rgba(20,184,166,.12) 71px 72px,transparent 73px),linear-gradient(135deg,rgba(255,255,255,.06) 1px,transparent 1px);--hero-pattern-size:220px 220px,42px 42px}.ati-cp-weekly-challenge{--hero-pattern:radial-gradient(circle at 18px 18px,rgba(255,196,0,.2) 0 2px,transparent 3px),linear-gradient(90deg,rgba(255,255,255,.07) 1px,transparent 1px);--hero-pattern-size:52px 52px,104px 104px}.ati-hero{position:relative;display:grid;grid-template-columns:minmax(0,1fr) 360px;gap:clamp(28px,6vw,90px);align-items:center;min-height:430px;padding:76px clamp(22px,10vw,160px);overflow:hidden;color:#fff;background:linear-gradient(90deg,rgba(0,0,0,.92),rgba(0,0,0,.6)),var(--hero) center\/cover no-repeat}.ati-hero:after{position:absolute;inset:0;content:\"\";background:var(--hero-pattern);background-size:var(--hero-pattern-size);opacity:var(--hero-pattern-opacity);mix-blend-mode:screen;pointer-events:none}.ati-hero>*{position:relative;z-index:1}.ati-label{margin:0 0 12px!important;color:#ffb000!important;font-size:13px!important;font-weight:800!important;letter-spacing:.08em;text-transform:uppercase}.ati-hero h1{max-width:840px;margin:0!important;color:#fff!important;font-size:clamp(42px,5vw,72px)!important;line-height:1.03!important;font-weight:800!important;letter-spacing:0}.ati-hero-title-line{display:block;color:#fff!important}.ati-hero-title-line.accent{color:#ffc400!important}.ati-word{display:inline-block;white-space:nowrap}.ati-word:not(:last-child){margin-right:.32em}.ati-letter{display:inline-block;opacity:0;transform:translateY(.34em);animation:ati-letter-in 520ms cubic-bezier(.2,.8,.2,1) forwards;animation-delay:calc(38ms * var(--i))}@keyframes ati-letter-in{0%{opacity:0;transform:translateY(.34em)}100%{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.ati-letter{opacity:1;transform:none;animation:none}}.ati-hero p:not(.ati-label){max-width:700px;margin:22px 0 0!important;color:rgba(255,255,255,.86)!important;font-size:19px!important}.ati-side{padding:28px;color:#fff;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.18);border-radius:8px;backdrop-filter:blur(18px)}.ati-side strong{display:block;color:#ffc400;font-size:22px;line-height:1.15;overflow-wrap:anywhere}.ati-side p{margin:12px 0 0!important;color:rgba(255,255,255,.78)!important}.ati-actions{display:flex;flex-wrap:wrap;gap:14px;margin-top:32px}.ati-btn{display:inline-flex;align-items:center;justify-content:center;min-height:54px;padding:0 28px;border-radius:8px;font-size:15px;font-weight:800}.ati-primary{color:#050505!important;background:linear-gradient(135deg,#ffc400,#ffb000);box-shadow:0 18px 38px rgba(255,196,0,.25)}.ati-secondary{color:#fff!important;border:1px solid #ffc400}\n.ati-section,.ati-about{max-width:1320px;margin:0 auto;padding:72px clamp(22px,6vw,64px)}.ati-heading{display:grid;grid-template-columns:.8fr 1.2fr;gap:40px;align-items:end;margin-bottom:32px}.ati-heading h2,.ati-split h2{margin:0!important;color:#050505!important;font-size:clamp(30px,4vw,48px)!important;line-height:1.08!important}.ati-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px}.ati-grid.five{grid-template-columns:repeat(5,minmax(0,1fr))}.ati-card{padding:26px;background:#fff;border:1px solid #e2e8f0;border-radius:8px;box-shadow:0 18px 45px rgba(15,23,42,.06)}.ati-card .ati-num{color:#b47c00;font-size:14px;font-weight:800;text-transform:uppercase}.ati-card h3{margin:12px 0 0!important;color:#050505!important;font-size:22px!important;line-height:1.12!important}.ati-card p{margin:12px 0 0!important;color:#172033!important}.ati-task-card h3{margin:0!important}.ati-task-card h3 .ati-num{display:inline;color:#b47c00;font-size:22px;line-height:1.12}.ati-task-card p{margin-top:14px!important}.ati-split{max-width:1320px;margin:0 auto;padding:72px clamp(22px,6vw,64px);display:grid;grid-template-columns:.85fr 1.15fr;gap:52px;border-top:1px solid #e2e8f0}.ati-list{display:grid;gap:14px}.ati-list article{padding:20px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}.ati-list b{display:block;color:#050505;font-size:18px}.ati-list span{display:block;margin-top:6px;color:#172033}.ati-dark{max-width:none;background:linear-gradient(135deg,#050505,#0f172a);color:#fff;border:0;padding-left:clamp(22px,10vw,160px);padding-right:clamp(22px,10vw,160px)}.ati-dark h2,.ati-dark p{color:#fff!important}.ati-dark .ati-list article{background:rgba(255,255,255,.06);border-color:rgba(255,255,255,.12)}.ati-dark .ati-list b{color:#ffc400}.ati-dark .ati-list span{color:rgba(255,255,255,.78)}.ati-path{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:16px}.ati-benefits{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.ati-benefits span{padding:18px 20px;color:#0f3d37;background:rgba(20,184,166,.1);border:1px solid rgba(20,184,166,.24);border-radius:8px;font-weight:800}.ati-side .ati-side-link{display:inline-flex;margin-top:18px;min-height:42px;padding:0 16px;align-items:center;justify-content:center;color:#050505!important;background:#ffc400;border-radius:8px;font-size:14px;font-weight:800}.ati-challenge-entry{max-width:1320px;margin:0 auto;padding:0 clamp(22px,6vw,64px) 72px}.ati-challenge-entry+.ati-challenge-entry{padding-top:0}.ati-challenge-panel{display:grid;grid-template-columns:1fr auto;gap:24px;align-items:center;padding:28px 30px;color:#fff;background:linear-gradient(135deg,#050505,#111827);border:1px solid rgba(255,196,0,.36);border-radius:8px;box-shadow:0 24px 55px rgba(15,23,42,.16)}.ati-challenge-entry h2{margin:0!important;color:#fff!important;font-size:clamp(24px,3vw,36px)!important;line-height:1.08!important}.ati-challenge-entry p{margin:8px 0 0!important;color:#dbe4ef!important}.ati-challenge-entry a{display:inline-flex;align-items:center;justify-content:center;min-height:46px;padding:0 20px;color:#050505!important;background:#ffc400;border-radius:8px;font-weight:800;white-space:nowrap}.ati-posts{display:grid;gap:18px}.ati-posts article{padding:26px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}.ati-posts h2{margin:0!important;color:#050505!important;font-size:28px!important}.ati-tag{color:#b47c00;font-size:13px;font-weight:800;text-transform:uppercase}\n.ati-assessment{display:grid;gap:18px}.ati-assessment-frame{display:block;width:100%;min-height:3300px;border:0;background:#f8fafc}.ati-embed{overflow:hidden;border:1px solid #1e293b;border-radius:8px;background:#050505;box-shadow:0 18px 45px rgba(15,23,42,.12)}.ati-embed iframe{display:block;width:100%;min-height:760px;border:0}.ati-levels{display:grid;gap:10px;margin:0;padding:0;list-style:none}.ati-levels li{padding:14px 16px;background:#fff;border:1px solid #e2e8f0;border-radius:8px;color:#172033}.ati-task-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}@media(max-width:800px){.ati-task-grid{grid-template-columns:1fr}.ati-assessment-frame{min-height:4300px}}\nbody .ati-wpforms .wpforms-container{margin:0!important}body .ati-wpforms form,body .ati-wpforms .wpforms-field-container{display:flex!important;flex-direction:column!important}body .ati-wpforms .wpforms-field{padding:10px 0 16px!important}body .ati-wpforms .wpforms-field.wpforms-field-text{display:none!important}body .ati-wpforms .wpforms-field.wpforms-field-select{order:-10!important}body .ati-wpforms .wpforms-field-label{font-weight:800!important;color:#050505!important}body .ati-wpforms .wpforms-field-row{max-width:100%!important}body .ati-wpforms .wpforms-field-row-block{width:100%!important;padding:0!important;margin-bottom:12px!important}body .ati-wpforms input,body .ati-wpforms textarea,body .ati-wpforms select{width:100%!important;max-width:100%!important;min-height:48px!important;padding:12px 14px!important;border:1px solid #e2e8f0!important;border-radius:8px!important;background:#f8fafc!important;color:#0f172a!important;font:inherit!important}body .ati-wpforms select{appearance:auto!important}body .ati-wpforms button[type=submit]{min-height:52px!important;padding:0 26px!important;border:0!important;border-radius:8px!important;color:#050505!important;background:linear-gradient(135deg,#ffc400,#ffb000)!important;box-shadow:0 18px 38px rgba(255,196,0,.24)!important;font-weight:800!important}\n#wpforms-76-field_5-container,#wpforms-76-field_6-container{display:none!important}#wpforms-76-field_4-container{order:-10!important}\n.ati-challenge-query .wp-block-post-template,.ati-challenge-posts{display:grid!important;gap:18px!important;padding:0!important;margin:0!important;list-style:none!important}.ati-challenge-query .wp-block-post,.ati-challenge-posts li{padding:26px!important;background:#fff!important;border:1px solid #e2e8f0!important;border-radius:8px!important;box-shadow:0 18px 45px rgba(15,23,42,.06)}.ati-challenge-query h2{margin:0!important}.ati-challenge-query h2 a,.ati-challenge-posts a{display:block;color:#050505!important;font-size:clamp(23px,2.8vw,31px);font-weight:800;line-height:1.12}.ati-challenge-query h2 a:hover,.ati-challenge-posts a:hover{color:#b47c00!important}.ati-challenge-query time,.ati-challenge-posts time{display:block;margin-top:10px;color:#b47c00;font-size:13px;font-weight:800;text-transform:uppercase}.ati-challenge-query .wp-block-post-excerpt,.ati-challenge-posts .wp-block-latest-posts__post-excerpt{margin:12px 0 0!important;color:#172033!important;font-size:16px;line-height:1.55}.ati-challenge-query .wp-block-post-excerpt__more-link{display:inline-flex;margin-top:14px;color:#b47c00!important;font-weight:800}.ati-article{max-width:1080px;margin:0 auto;padding:72px clamp(22px,6vw,64px);font-size:18px;line-height:1.7}.ati-article-card{padding:clamp(28px,5vw,56px);background:#fff;border:1px solid #e2e8f0;border-radius:8px;box-shadow:0 18px 45px rgba(15,23,42,.06)}.ati-article-card p{margin:0 0 22px!important;color:#172033!important}.ati-article-card h2{margin:42px 0 14px!important;color:#050505!important;font-size:clamp(25px,3vw,36px)!important;line-height:1.1!important}.ati-article-card ul{margin:0 0 24px 22px!important;color:#172033}.ati-article-card li{margin:8px 0}.ati-article-card pre{overflow:auto;margin:16px 0 28px!important;padding:20px!important;color:#f8fafc!important;background:#0b1020!important;border:1px solid #1e293b;border-radius:8px;font-size:14px;line-height:1.55}.ati-article-card pre code{display:block!important;padding:0!important;color:#f8fafc!important;background:transparent!important;border:0!important;font-family:Menlo,Consolas,monospace;white-space:pre}.ati-back-link{display:inline-flex;margin-bottom:18px;color:#b47c00!important;font-size:14px;font-weight:800}\n.ati-footer{display:grid;grid-template-columns:1fr auto 1fr;gap:24px;align-items:center;min-height:90px;padding:22px clamp(22px,10vw,160px);color:#f8fafc;background:#050505;text-rendering:geometricPrecision;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.ati-footer .ati-logo img{height:36px;max-width:240px}.ati-footer a{color:#f8fafc!important}.ati-footer a:hover{color:#ffc400!important}.ati-footer nav{display:flex;flex-wrap:wrap;gap:24px;justify-content:center;font-size:14px;font-weight:600;line-height:1.35}.ati-footer address{display:grid;gap:5px;justify-self:end;color:#dbe4ef;font-size:14.5px;font-weight:500;line-height:1.35;font-style:normal;margin:0!important}.ati-footer address a{font-weight:700}.ati-footer address span{color:#cbd5e1}\n.ati-menu-toggle,.ati-menu-button{display:none}@media(max-width:1100px){.ati-top,.ati-hero,.ati-heading,.ati-grid,.ati-grid.five,.ati-split,.ati-path,.ati-footer,.ati-challenge-panel{grid-template-columns:1fr}.ati-header-cta,.ati-footer address{justify-self:start}.ati-nav{justify-content:flex-start;flex-wrap:wrap}.ati-split{gap:30px}.ati-benefits{grid-template-columns:1fr}.ati-challenge-entry a{justify-self:start}}@media(max-width:700px){.ati-top{display:grid!important;grid-template-columns:1fr auto!important;align-items:center!important;gap:0!important;padding:16px 22px!important}.ati-logo img{height:34px}.ati-menu-button{display:grid;gap:5px;place-content:center;width:44px;height:40px;color:#fff;border:1px solid rgba(255,255,255,.22);border-radius:8px;cursor:pointer}.ati-menu-button span{display:block;width:20px;height:2px;background:#ffc400;border-radius:999px}.ati-nav{display:none!important;grid-column:1\/-1;width:100%;gap:0;margin-top:14px;padding:10px 0;border-top:1px solid rgba(255,255,255,.1)}.ati-nav a{padding:11px 0!important}.ati-nav a:after{bottom:5px}.ati-header-cta{display:none!important}.ati-menu-toggle:checked~.ati-nav{display:grid!important}.ati-menu-toggle:checked~.ati-header-cta{display:inline-flex!important;grid-column:1\/-1;justify-self:start;margin-top:12px}.ati-hero{min-height:auto;padding:60px 22px}.ati-hero h1{font-size:40px!important}.ati-footer nav{justify-content:flex-start}}\n@media(max-width:1100px){.ati-top{display:grid!important;grid-template-columns:1fr auto!important;align-items:center!important;gap:0!important;padding:16px 22px!important}.ati-logo img{height:34px}.ati-menu-button{display:grid!important;gap:5px;place-content:center;width:44px;height:40px;color:#fff;border:1px solid rgba(255,255,255,.22);border-radius:8px;cursor:pointer}.ati-menu-button span{display:block;width:20px;height:2px;background:#ffc400;border-radius:999px}.ati-nav{display:none!important;grid-column:1\/-1;width:100%;gap:0;margin-top:14px;padding:10px 0;border-top:1px solid rgba(255,255,255,.1)}.ati-nav a{padding:11px 0!important}.ati-nav a:after{bottom:5px}.ati-header-cta{display:none!important}.ati-menu-toggle:checked~.ati-nav{display:grid!important}.ati-menu-toggle:checked~.ati-header-cta{display:inline-flex!important;grid-column:1\/-1;justify-self:start;margin-top:12px}}\n.ati-mobile-menu{display:none}.ati-mobile-menu summary{list-style:none}.ati-mobile-menu summary::-webkit-details-marker{display:none}@media(max-width:1100px){.ati-mobile-menu{display:block!important;position:absolute!important;top:18px!important;right:22px!important;z-index:9999!important}.ati-mobile-menu summary{display:grid!important;gap:5px;place-content:center;width:44px;height:40px;border:1px solid rgba(255,255,255,.22);border-radius:8px;background:#050505;cursor:pointer}.ati-mobile-menu summary span{display:block;width:20px;height:2px;background:#ffc400;border-radius:999px}.ati-mobile-menu summary:before{display:block;width:20px;height:2px;content:\"\";background:#ffc400;border-radius:999px;box-shadow:0 7px 0 #ffc400,0 14px 0 #ffc400}.ati-mobile-menu summary span{display:none}.ati-mobile-menu[open] summary{border-color:rgba(255,196,0,.62);background:rgba(255,196,0,.1)}.ati-mobile-panel{position:absolute;top:52px;right:0;display:grid;gap:2px;width:min(78vw,320px);padding:12px;background:#050505;border:1px solid rgba(255,255,255,.14);border-radius:8px;box-shadow:0 24px 60px rgba(0,0,0,.46)}.ati-mobile-panel a{display:block;padding:12px 14px;color:#f8fafc!important;border-radius:6px;font-size:15px;font-weight:800;line-height:1.2}.ati-mobile-panel a.active,.ati-mobile-panel a:hover{color:#ffc400!important;background:rgba(255,255,255,.06)}.ati-mobile-panel .ati-mobile-cta{margin-top:6px;color:#050505!important;background:#ffc400;text-align:center}.ati-mobile-panel .ati-mobile-cta:hover{color:#050505!important;background:#ffcf33}}\n.ati-mobile-menu-button{position:absolute!important;top:18px!important;right:22px!important;z-index:10000!important;display:grid!important;place-content:center;width:44px;height:40px;color:#ffc400!important;border:1px solid rgba(255,255,255,.24);border-radius:8px;background:#050505;font-size:27px!important;font-weight:800;line-height:1;text-decoration:none!important}.ati-mobile-menu-button:before{display:none!important}.ati-mobile-nav-panel{display:none;position:absolute!important;top:70px!important;right:22px!important;z-index:10000!important;width:min(78vw,320px);padding:12px;background:#050505;border:1px solid rgba(255,255,255,.14);border-radius:8px;box-shadow:0 24px 60px rgba(0,0,0,.46)}.ati-mobile-nav-panel:target{display:grid!important;gap:2px}.ati-mobile-nav-panel a{display:block;padding:12px 14px;color:#f8fafc!important;border-radius:6px;font-size:15px;font-weight:800;line-height:1.2}.ati-mobile-nav-panel a.active,.ati-mobile-nav-panel a:hover{color:#ffc400!important;background:rgba(255,255,255,.06)}.ati-mobile-nav-panel .ati-mobile-cta{margin-top:6px;color:#050505!important;background:#ffc400;text-align:center}.ati-mobile-nav-panel .ati-mobile-close{color:#94a3b8!important;text-align:center;font-size:13px}@media(min-width:1101px){.ati-mobile-menu-button,.ati-mobile-nav-panel{display:none!important}}@media(max-width:1100px){.ati-mobile-menu{display:none!important}}\n.trp-language-switcher.trp-floating-switcher{position:fixed!important;top:auto!important;right:22px!important;bottom:22px!important;z-index:10001!important;width:auto!important;min-width:118px!important;--bottom:22px!important;--right:22px!important;--border-radius:8px!important;--bg:#050505!important;--bg-hover:rgba(255,255,255,.08)!important;--text:#f8fafc!important;--text-hover:#ffc400!important;--border:1px solid rgba(255,255,255,.2)!important}.trp-language-switcher .trp-language-switcher-inner{background:#050505!important;border-color:rgba(255,255,255,.2)!important;border-radius:8px!important;box-shadow:0 18px 42px rgba(0,0,0,.28)!important}.trp-language-switcher .trp-language-item{color:#f8fafc!important;font-weight:800!important}.trp-language-switcher .trp-language-item:hover{color:#ffc400!important;background:rgba(255,255,255,.08)!important}.trp-language-switcher .trp-flag-image{display:none!important}.trp-language-switcher .trp-language-item-name{margin-left:0!important}.ati-header-cta{margin-right:0}@media(max-width:1100px){.trp-language-switcher.trp-floating-switcher{right:18px!important;bottom:18px!important;min-width:118px!important;--bottom:18px!important;--right:18px!important}}\n<\/style>\n<style>\n.ati-article-shell{max-width:980px;margin:0 auto;padding:72px clamp(22px,6vw,64px)}\n.ati-article-card{background:#fff;border:1px solid #e2e8f0;border-radius:8px;box-shadow:0 18px 45px rgba(15,23,42,.06);padding:clamp(26px,5vw,58px)}\n.ati-article-meta{display:flex;flex-wrap:wrap;gap:10px 14px;margin:18px 0 0;color:rgba(255,255,255,.78);font-size:14px;font-weight:700}\n.ati-article-content{color:#172033;font-size:18px;line-height:1.72}\n.ati-article-content p{margin:0 0 1.1em!important;color:#172033!important}\n.ati-article-content h2{margin:2em 0 .65em!important;color:#050505!important;font-size:clamp(26px,3vw,36px)!important;line-height:1.12!important}\n.ati-article-content h3{margin:1.45em 0 .45em!important;color:#050505!important;font-size:22px!important;line-height:1.2!important}\n.ati-article-content ul,.ati-article-content ol{margin:0 0 1.2em 1.4em!important;padding:0!important}\n.ati-article-content li{margin:.35em 0!important}\n.ati-article-content pre{margin:1.4em 0!important;padding:18px 20px!important;overflow:auto;color:#e5e7eb;background:#0f172a;border-radius:8px;line-height:1.55;font-size:14px}\n.ati-article-content code{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",monospace}\n.ati-article-content p code,.ati-article-content li code{padding:.1em .32em;background:#f1f5f9;border:1px solid #e2e8f0;border-radius:5px;color:#0f172a;font-size:.92em}\n.ati-article-content a{color:#b47c00!important;font-weight:800;text-decoration:none}\n.ati-article-content a:hover{text-decoration:underline}\n.ati-article-back{margin-top:28px;padding-top:22px;border-top:1px solid #e2e8f0}\n@media(max-width:800px){.ati-article-shell{padding:44px 18px}.ati-article-card{padding:24px 18px}.ati-article-content{font-size:16px}.ati-article-content pre{font-size:13px}}\n<\/style>\n<div class=\"ati-page ati-resource-post\" style=\"--hero:url(https:\/\/i0.wp.com\/accelthinking.com\/wp-content\/uploads\/2026\/06\/hero-technology-education-51.png?w=1600&amp;quality=85&amp;ssl=1)\">\n<header class=\"ati-top\">\n      <a class=\"ati-brand ati-logo\" href=\"\/zh_cn\/\" aria-label=\"Accel Thinking home\"><img loading=\"lazy\" decoding=\"async\" height=\"63\" width=\"366\" src=\"https:\/\/i0.wp.com\/accelthinking.com\/wp-content\/uploads\/2026\/06\/logo-dark-cropped-51.png?w=480&amp;quality=85&amp;ssl=1\" alt=\"Accel Thinking\"><\/a><br>\n      <input class=\"ati-menu-toggle\" id=\"ati-menu-post\" type=\"checkbox\" aria-label=\"Toggle navigation menu\"><br>\n      <label class=\"ati-menu-button\" for=\"ati-menu-post\" aria-hidden=\"true\"><span><\/span><span><\/span><span><\/span><\/label>\n<details class=\"ati-mobile-menu\">\n<summary aria-label=\"Open navigation menu\"><span><\/span><span><\/span><span><\/span><\/summary>\n<div class=\"ati-mobile-panel\"><a class=\"\" href=\"\/zh_cn\/\">\u9996\u9875<\/a><a class=\"\" href=\"\/zh_cn\/northstar\/\">\u5317\u6781\u661f<\/a><a class=\"\" href=\"\/zh_cn\/learning\/\">\u5b66\u4e60\u8def\u5f84<\/a><a class=\"active\" href=\"\/zh_cn\/resources\/\">\u8d44\u6e90\u6587\u7ae0<\/a><a class=\"\" href=\"\/zh_cn\/about\/\">\u5173\u4e8e\u6211\u4eec<\/a><a class=\"\" href=\"\/zh_cn\/contact\/\">\u8054\u7cfb\u6211\u4eec<\/a><a class=\"ati-mobile-cta\" href=\"\/zh_cn\/northstar\/\">\u5f00\u59cb\u5317\u6781\u661f\u6d4b\u8bc4<\/a><\/div>\n<\/details>\n<p>      <a class=\"ati-mobile-menu-button\" href=\"#ati-mobile-nav-post\" aria-label=\"Open navigation menu\">\u2630<\/a><\/p>\n<nav id=\"ati-mobile-nav-post\" class=\"ati-mobile-nav-panel\"><a class=\"\" href=\"\/zh_cn\/\">\u9996\u9875<\/a><a class=\"\" href=\"\/zh_cn\/northstar\/\">\u5317\u6781\u661f<\/a><a class=\"\" href=\"\/zh_cn\/learning\/\">\u5b66\u4e60\u8def\u5f84<\/a><a class=\"active\" href=\"\/zh_cn\/resources\/\">\u8d44\u6e90\u6587\u7ae0<\/a><a class=\"\" href=\"\/zh_cn\/about\/\">\u5173\u4e8e\u6211\u4eec<\/a><a class=\"\" href=\"\/zh_cn\/contact\/\">\u8054\u7cfb\u6211\u4eec<\/a><a class=\"ati-mobile-cta\" href=\"\/zh_cn\/northstar\/\">\u5f00\u59cb\u5317\u6781\u661f\u6d4b\u8bc4<\/a><a class=\"ati-mobile-close\" href=\"#\">\u5173\u95ed<\/a><\/nav>\n<nav class=\"ati-nav\"><a class=\"\" href=\"\/zh_cn\/\">\u9996\u9875<\/a><a class=\"\" href=\"\/zh_cn\/northstar\/\">\u5317\u6781\u661f<\/a><a class=\"\" href=\"\/zh_cn\/learning\/\">\u5b66\u4e60\u8def\u5f84<\/a><a class=\"active\" href=\"\/zh_cn\/resources\/\">\u8d44\u6e90\u6587\u7ae0<\/a><a class=\"\" href=\"\/zh_cn\/about\/\">\u5173\u4e8e\u6211\u4eec<\/a><a class=\"\" href=\"\/zh_cn\/contact\/\">\u8054\u7cfb\u6211\u4eec<\/a><\/nav>\n<p>      <a class=\"ati-header-cta\" href=\"\/zh_cn\/northstar\/\">\u5f00\u59cb\u5317\u6781\u661f\u6d4b\u8bc4<\/a><br>\n    <\/p><\/header>\n<p>    <main><\/main><\/p>\n<section class=\"ati-hero ati-lang-en\">\n<div>\n<p class=\"ati-label\">CP \u6bcf\u5468\u7f16\u7a0b\u6311\u6218<\/p>\n<h1 aria-label=\"CCC 2023 S2 Symmetric Mountains Solution: Center Expansion for Minimum Asymmetry at Every Length\"><span class=\"ati-hero-title-line\"><span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:0\">C<\/span><span class=\"ati-letter\" style=\"--i:1\">C<\/span><span class=\"ati-letter\" style=\"--i:2\">C<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:4\">2<\/span><span class=\"ati-letter\" style=\"--i:5\">0<\/span><span class=\"ati-letter\" style=\"--i:6\">2<\/span><span class=\"ati-letter\" style=\"--i:7\">3<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:9\">S<\/span><span class=\"ati-letter\" style=\"--i:10\">2<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:12\">S<\/span><span class=\"ati-letter\" style=\"--i:13\">y<\/span><span class=\"ati-letter\" style=\"--i:14\">m<\/span><span class=\"ati-letter\" style=\"--i:15\">m<\/span><span class=\"ati-letter\" style=\"--i:16\">e<\/span><span class=\"ati-letter\" style=\"--i:17\">t<\/span><span class=\"ati-letter\" style=\"--i:18\">r<\/span><span class=\"ati-letter\" style=\"--i:19\">i<\/span><span class=\"ati-letter\" style=\"--i:20\">c<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:22\">M<\/span><span class=\"ati-letter\" style=\"--i:23\">o<\/span><span class=\"ati-letter\" style=\"--i:24\">u<\/span><span class=\"ati-letter\" style=\"--i:25\">n<\/span><span class=\"ati-letter\" style=\"--i:26\">t<\/span><span class=\"ati-letter\" style=\"--i:27\">a<\/span><span class=\"ati-letter\" style=\"--i:28\">i<\/span><span class=\"ati-letter\" style=\"--i:29\">n<\/span><span class=\"ati-letter\" style=\"--i:30\">s<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:32\">S<\/span><span class=\"ati-letter\" style=\"--i:33\">o<\/span><span class=\"ati-letter\" style=\"--i:34\">l<\/span><span class=\"ati-letter\" style=\"--i:35\">u<\/span><span class=\"ati-letter\" style=\"--i:36\">t<\/span><span class=\"ati-letter\" style=\"--i:37\">i<\/span><span class=\"ati-letter\" style=\"--i:38\">o<\/span><span class=\"ati-letter\" style=\"--i:39\">n<\/span><span class=\"ati-letter\" style=\"--i:40\">:<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:42\">C<\/span><span class=\"ati-letter\" style=\"--i:43\">e<\/span><span class=\"ati-letter\" style=\"--i:44\">n<\/span><span class=\"ati-letter\" style=\"--i:45\">t<\/span><span class=\"ati-letter\" style=\"--i:46\">e<\/span><span class=\"ati-letter\" style=\"--i:47\">r<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:49\">E<\/span><span class=\"ati-letter\" style=\"--i:50\">x<\/span><span class=\"ati-letter\" style=\"--i:51\">p<\/span><span class=\"ati-letter\" style=\"--i:52\">a<\/span><span class=\"ati-letter\" style=\"--i:53\">n<\/span><span class=\"ati-letter\" style=\"--i:54\">s<\/span><span class=\"ati-letter\" style=\"--i:55\">i<\/span><span class=\"ati-letter\" style=\"--i:56\">o<\/span><span class=\"ati-letter\" style=\"--i:57\">n<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:59\">f<\/span><span class=\"ati-letter\" style=\"--i:60\">o<\/span><span class=\"ati-letter\" style=\"--i:61\">r<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:63\">M<\/span><span class=\"ati-letter\" style=\"--i:64\">i<\/span><span class=\"ati-letter\" style=\"--i:65\">n<\/span><span class=\"ati-letter\" style=\"--i:66\">i<\/span><span class=\"ati-letter\" style=\"--i:67\">m<\/span><span class=\"ati-letter\" style=\"--i:68\">u<\/span><span class=\"ati-letter\" style=\"--i:69\">m<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:71\">A<\/span><span class=\"ati-letter\" style=\"--i:72\">s<\/span><span class=\"ati-letter\" style=\"--i:73\">y<\/span><span class=\"ati-letter\" style=\"--i:74\">m<\/span><span class=\"ati-letter\" style=\"--i:75\">m<\/span><span class=\"ati-letter\" style=\"--i:76\">e<\/span><span class=\"ati-letter\" style=\"--i:77\">t<\/span><span class=\"ati-letter\" style=\"--i:78\">r<\/span><span class=\"ati-letter\" style=\"--i:79\">y<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:81\">a<\/span><span class=\"ati-letter\" style=\"--i:82\">t<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:84\">E<\/span><span class=\"ati-letter\" style=\"--i:85\">v<\/span><span class=\"ati-letter\" style=\"--i:86\">e<\/span><span class=\"ati-letter\" style=\"--i:87\">r<\/span><span class=\"ati-letter\" style=\"--i:88\">y<\/span><\/span> <span class=\"ati-word\"><span class=\"ati-letter\" style=\"--i:90\">L<\/span><span class=\"ati-letter\" style=\"--i:91\">e<\/span><span class=\"ati-letter\" style=\"--i:92\">n<\/span><span class=\"ati-letter\" style=\"--i:93\">g<\/span><span class=\"ati-letter\" style=\"--i:94\">t<\/span><span class=\"ati-letter\" style=\"--i:95\">h<\/span><\/span><\/span><\/h1>\n<p>Fix each odd or even center, expand outward, and find the minimum asymmetry for every crop length in O(N\u00b2).<\/p>\n<div class=\"ati-article-meta\"><span>\u4f5c\u8005\uff1aBerny<\/span><span>October 3, 2026<\/span><\/div>\n<\/div>\n<aside class=\"ati-side\"><strong>Center Expansion<br>Odd &amp; Even Centers<br>O(N\u00b2)<\/strong>\n<p>Each interval has one center, so every outward step adds exactly one mirrored pair.<\/p>\n<\/aside>\n<\/section>\n<section class=\"ati-hero ati-lang-zh\">\n<div>\n<p class=\"ati-label\">CP \u6bcf\u5468\u7f16\u7a0b\u6311\u6218<\/p>\n<h1 aria-label=\"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\uff0cO(N\u00b2) \u6c42\u6bcf\u4e2a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\">CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\uff0cO(N\u00b2) \u6c42\u6bcf\u4e2a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c<\/h1>\n<p>\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002<\/p>\n<div class=\"ati-article-meta\"><span>\u4f5c\u8005\uff1aBerny<\/span><span>2026 \u5e74 10 \u6708 3 \u65e5<\/span><\/div>\n<\/div>\n<aside class=\"ati-side\"><strong>\u4e2d\u5fc3\u6269\u5c55<br>\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3<br>O(N\u00b2)<\/strong>\n<p>\u6bcf\u4e2a\u533a\u95f4\u53ea\u6709\u4e00\u4e2a\u4e2d\u5fc3\uff0c\u6bcf\u6b21\u5411\u5916\u6269\u5c55\u53ea\u65b0\u589e\u4e00\u5bf9\u955c\u50cf\u4f4d\u7f6e\u3002<\/p>\n<\/aside>\n<\/section>\n<section class=\"ati-article-shell\">\n<article class=\"ati-article-card\">\n<div class=\"ati-share-tools\" data-ati-share>\n<div class=\"ati-share-copy\">\n<p class=\"ati-share-kicker\">\u5206\u4eab\u8fd9\u7bc7\u6587\u7ae0<\/p>\n<p class=\"ati-share-note\">\u590d\u5236\u94fe\u63a5\u3001\u4f7f\u7528\u624b\u673a\u5206\u4eab\u3001\u7528\u5fae\u4fe1\u626b\u7801\uff0c\u6216\u901a\u8fc7\u90ae\u4ef6\u53d1\u9001\u3002<\/p>\n<\/div>\n<div class=\"ati-share-actions\">\n    <button type=\"button\" data-share-native>\u5206\u4eab<\/button><br>\n    <button type=\"button\" data-share-copy-link>\u590d\u5236\u94fe\u63a5<\/button><br>\n    <button type=\"button\" data-share-wechat>\u5fae\u4fe1\u4e8c\u7ef4\u7801<\/button><br>\n    <a data-share-email>\u90ae\u7bb1<\/a>\n  <\/div>\n<div class=\"ati-share-qr\" data-share-qr hidden>\n    <img loading=\"lazy\" data-share-qr-img alt=\"QR code for sharing this article\">\n<p>\u4f7f\u7528\u5fae\u4fe1\u626b\u7801\uff0c\u7136\u540e\u5206\u4eab\u6587\u7ae0\u94fe\u63a5\u3002<\/p>\n<\/div>\n<p class=\"ati-share-status\" data-share-status aria-live=\"polite\">\n<\/p><\/div>\n<div class=\"ati-article-content ati-lang-en\">\n<article class=\"ati-post-article\">\n<p>A row of mountains is photographed, and any contiguous crop [l, r] has an \"asymmetric value\": pair up mountains that are equidistant from the center, sum the absolute height differences. The task asks for more than one crop's answer \u2014 for <strong>every length k from 1 to N, the minimum asymmetric value among all crops of that length<\/strong>. CCC 2023 Senior Problem 2, Symmetric Mountains, looks like it requires enumerating a massive number of intervals. What it really tests is whether you can see that every interval has exactly one center, and eliminate the repeated work. The whole algorithm is one idea: fix a center, expand outward.<\/p>\n<p><strong>Companion video:<\/strong> <a href=\"https:\/\/www.xiaohongshu.com\/discovery\/item\/6ac1c2640000000002028378\">Watch Berny's 2023 S2 Symmetric Mountains walkthrough on Xiaohongshu<\/a><\/p>\n<h2>\u672c\u9898\u5728 CCC \u6570\u636e\u7ed3\u6784\u4e0e\u7b97\u6cd5\u8def\u7ebf\u56fe\u4e2d\u7684\u4f4d\u7f6e<\/h2>\n<ul>\n<li>Level: Senior S2<\/li>\n<li>Pattern: Center Expansion (two pointers moving outward)<\/li>\n<li>Prerequisite: arrays and indexing, loops, <code>abs()<\/code>, Big-O basics (<a href=\"\/zh_cn\/python-syntax-basics-input-operators-conditions\/\">Python basics: input, operators, and conditions<\/a>, <a href=\"\/zh_cn\/python-list-append-vs-plus\/\">Python list fundamentals<\/a>)<\/li>\n<li>What this teaches: turn \"every interval has exactly one center\" into an incremental recurrence (each step adds exactly one pair), then aggregate minima by length \u2014 recognize and remove repeated work<\/li>\n<li>Where it appears again: palindrome checking and longest palindromic substring, the two-pointer \/ sliding-window topic (planned), CPW-012 Searching for Strings (planned)<\/li>\n<\/ul>\n<h2>What to Study Next<\/h2>\n<ul>\n<li>Related CP Weekly problems: <a href=\"\/zh_cn\/ccc-2017-s1-sum-game-solution-analysis\/\">CCC 2017 S1 Sum Game<\/a> for prefix sums and interval sums, CCC 2020 S3 Searching for Strings for sliding windows (coming soon), and CCC 2016 J5\/S2 Tandem Bicycle for sorting with two pointers (coming soon)<\/li>\n<li>Related Python \/ C++ foundations: <a href=\"\/zh_cn\/python-syntax-basics-input-operators-conditions\/\">Python Basics: Input, Operators, and Conditions<\/a>, <a href=\"\/zh_cn\/python-list-append-vs-plus\/\">Python Lists: append() vs +<\/a><\/li>\n<li>Related DSA roadmap article: Prefix Sum and Sliding Window Patterns (planned)<\/li>\n<\/ul>\n<h2>What the Problem Is Asking<\/h2>\n<p>The input gives N mountain heights h\u2081\u2026h\u2099. A crop is a contiguous interval [l, r]; its asymmetric value is the sum of absolute differences of mirrored positions: |h_l \u2212 h_r| + |h_{l+1} \u2212 h_{r\u22121}| + \u2026<\/p>\n<p>Output N integers: the k-th one is the <strong>minimum asymmetric value among all crops of length k<\/strong>.<\/p>\n<p>Official sample: N=7, heights <code>[3 1 4 1 5 9 2]<\/code>, answer <code>0 2 0 5 2 10 10<\/code>.<\/p>\n<p>Read the original problem in the <a href=\"https:\/\/cemc.uwaterloo.ca\/sites\/default\/files\/documents\/2023\/2023CCCSrProblemSet.html\">CEMC 2023 CCC Senior problem set<\/a>.<\/p>\n<p>Bounds: <code>1 \u2264 N \u2264 5000<\/code>, <code>0 \u2264 h_i \u2264 10^5<\/code>, with layered subtasks: N\u2264300 yields to brute force; the middle subtask has non-decreasing heights (where prefix sums can split the absolute values); full marks have no extra constraints \u2014 and center expansion handles all of them.<\/p>\n<h2>Where Beginners Often Get Stuck<\/h2>\n<ul>\n<li><strong>Sorting first<\/strong>: sorting makes absolute values easy to split, but it reorders the mountains \u2014 the photograph changes and so does every interval. <strong>Sorting is forbidden here.<\/strong><\/li>\n<li><strong>Brute force by length<\/strong>: enumerating every start for every length and recomputing each asymmetry from scratch is O(N\u00b3) \u2014 about 10\u00b9\u00b9 operations at N=5000, hopeless.<\/li>\n<li><strong>Forgetting even centers<\/strong>: odd-length crops are centered on a mountain; even-length crops are centered on the gap between two mountains. Writing only one kind misses half the intervals.<\/li>\n<li><strong>Initializing the answer array to 0<\/strong>: each length asks for a minimum, so the initial value must be infinity before taking min.<\/li>\n<li><strong>Prefix-sum splitting for general data<\/strong>: splitting |a\u2212b| requires knowing the order; full-mark data has no monotonicity, so that trick dies on subtask 3.<\/li>\n<\/ul>\n<h2>Core Algorithm Idea<\/h2>\n<p>Expand the definition of a crop [l, r]:<\/p>\n<pre><code class=\"language-text\">asym(l, r) = |h_l \u2212 h_r| + |h_{l+1} \u2212 h_{r\u22121}| + |h_{l+2} \u2212 h_{r\u22122}| + \u2026<\/code><\/pre>\n<p>Except for the outermost pair, <strong>everything inside the brackets is exactly asym(l+1, r\u22121)<\/strong>. That gives an incremental recurrence:<\/p>\n<pre><code class=\"language-text\">asym(l, r) = |h_l \u2212 h_r| + asym(l+1, r\u22121)<\/code><\/pre>\n<p>Empty intervals and single mountains cost 0. So if intervals are generated by \"fix a center, expand outward\", each expansion step only adds the newly exposed pair \u2014 the inner value is already in the accumulator, and <strong>no pair is ever computed twice<\/strong>.<\/p>\n<p>Every interval [l, r] has exactly one center: an index c for odd lengths, a gap (c, c+1) for even lengths. Enumerating all centers (N position centers plus N\u22121 gap centers) and expanding outward covers all N(N+1)\/2 intervals.<\/p>\n<h2>State \/ Data Structure Design<\/h2>\n<ul>\n<li><code>ans[k]<\/code>: the minimum asymmetric value among crops of length k (k = 1..N), initialized to infinity.<\/li>\n<li>Transient expansion state: <code>left<\/code>, <code>right<\/code>, <code>cost<\/code> \u2014 the current interval's endpoints and its accumulated asymmetry.<\/li>\n<\/ul>\n<p>Each expansion produces one interval and updates <code>ans[r \u2212 l + 1]<\/code> with <code>cost<\/code>. The intervals themselves never need to be stored.<\/p>\n<h2>Algorithm Steps<\/h2>\n<ol>\n<li>Read N and the height array h.<\/li>\n<li>Initialize <code>ans[1..N]<\/code> to infinity.<\/li>\n<li>For each position center c (0..N\u22121): start from l=r=c with cost=0; each step adds |h[l] \u2212 h[r]|, updates ans[r\u2212l+1] with cost, then moves l left and r right until out of bounds.<\/li>\n<li>For each gap center c (0..N\u22122): start from l=c, r=c+1, and expand the same way.<\/li>\n<li>Print ans[1..N], space-separated.<\/li>\n<\/ol>\n<h2>Sample Check with the Official Data<\/h2>\n<p>Verifying each length against the sample <code>[3 1 4 1 5 9 2]<\/code> (0-based indices):<\/p>\n<div class=\"ati-table-wrap\">\n<table>\n<thead>\n<tr>\n<th>Length<\/th>\n<th>Best crop<\/th>\n<th>Asymmetry<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>any single mountain<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>[3 1]<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>[1 4 1]<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>[3 1 4 1] or [1 5 9 2]<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>[3 1 4 1 5]<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>[1 4 1 5 9 2]<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>all seven<\/td>\n<td>10<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Watch center 2 (the mountain of height 4) grow the crop [3 1 4 1 5]: (4,4) adds 0; expanding to (1,3) adds |1\u22121|=0; expanding to (0,4) adds |3\u22125|=2 \u2014 three steps, one new pair each. The official explanation lists the three length-5 crops as costing 2, 9, and 10; the minimum 2 matches the output.<\/p>\n<h2>Python \u89e3\u6cd5<\/h2>\n<pre><code class=\"language-python\">n = int(input())\nmountains = list(map(int, input().split()))\nanswer = [10**18] * (n + 1)\n\nfor center in range(n):\n    cost = 0\n    left = center\n    right = center\n    while left &gt;= 0 and right &lt; n:\n        cost += abs(mountains[left] - mountains[right])\n        length = right - left + 1\n        answer[length] = min(answer[length], cost)\n        left -= 1\n        right += 1\n\nfor center in range(n - 1):\n    cost = 0\n    left = center\n    right = center + 1\n    while left &gt;= 0 and right &lt; n:\n        cost += abs(mountains[left] - mountains[right])\n        length = right - left + 1\n        answer[length] = min(answer[length], cost)\n        left -= 1\n        right += 1\n\nprint(*answer[1:])<\/code><\/pre>\n<p>This matches the curriculum notebook (p2003, Session 3) line for line \u2014 same variable names students see in class: <code>mountains<\/code>, <code>center<\/code>, <code>cost<\/code>, <code>answer<\/code>. Note that <code>cost<\/code> grows monotonically during one expansion, but lengths do not share answers \u2014 you cannot prune an expansion early just because the cost already exceeds some length's record.<\/p>\n<h2>C++ \u89e3\u6cd5<\/h2>\n<pre><code class=\"language-cpp\">#include &lt;algorithm&gt;\n#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;cstdlib&gt;\nusing namespace std;\n\nint main() {\n    int n;\n    cin &gt;&gt; n;\n    vector&lt;int&gt; mountains(n);\n    for (int&amp; height : mountains) {\n        cin &gt;&gt; height;\n    }\n\n    const long long INF = (1LL &lt;&lt; 60);\n    vector&lt;long long&gt; answer(n + 1, INF);\n\n    for (int center = 0; center &lt; n; center++) {\n        long long cost = 0;\n        int left = center;\n        int right = center;\n        while (left &gt;= 0 &amp;&amp; right &lt; n) {\n            cost += abs(mountains[left] - mountains[right]);\n            int length = right - left + 1;\n            answer[length] = min(answer[length], cost);\n            left--;\n            right++;\n        }\n    }\n\n    for (int center = 0; center + 1 &lt; n; center++) {\n        long long cost = 0;\n        int left = center;\n        int right = center + 1;\n        while (left &gt;= 0 &amp;&amp; right &lt; n) {\n            cost += abs(mountains[left] - mountains[right]);\n            int length = right - left + 1;\n            answer[length] = min(answer[length], cost);\n            left--;\n            right++;\n        }\n    }\n\n    for (int length = 1; length &lt;= n; length++) {\n        if (length &gt; 1) {\n            cout &lt;&lt; &#x27; &#x27;;\n        }\n        cout &lt;&lt; answer[length];\n    }\n    cout &lt;&lt; &#x27;\\n&#x27;;\n    return 0;\n}<\/code><\/pre>\n<p>Same as the curriculum reference; <code>long long<\/code> guards against overflow (worst case about \u230aN\/2\u230b\u00d710\u2075); <code>answer<\/code> starts from a <code>(1LL &lt;&lt; 60)<\/code>-scale infinity; the two loops are perfectly symmetric except for the initial (left, right).<\/p>\n<h2>Why the Algorithm Is Correct<\/h2>\n<ul>\n<li><strong>Every interval is visited exactly once<\/strong>: any interval [l, r] has a unique center (a position or a gap), its expansion from that center passes through [l, r], and intervals generated from different centers never overlap.<\/li>\n<li><strong>Each updated <code>cost<\/code> equals the true asym(l, r)<\/strong>: induction on the expansion radius. Radius 0 (or the gap initial state) gives length 1 (or 2), where cost = 0 plus the first pair \u2014 correct. Assuming the inner [l+1, r\u22121] value is correct, expanding to [l, r] adds exactly the outermost pair |h_l \u2212 h_r|, and the recurrence asym(l, r) = |h_l \u2212 h_r| + asym(l+1, r\u22121) makes it correct.<\/li>\n<li><strong>ans[k] ends as the minimum over all crops of length k<\/strong>: every crop of length k is computed during its center's expansion and participates in the min \u2014 no omissions, no duplicates.<\/li>\n<\/ul>\n<p>Therefore the output is exactly the requested minimum asymmetric value for every length.<\/p>\n<h2>\u590d\u6742\u5ea6\u5206\u6790<\/h2>\n<ul>\n<li>Time O(N\u00b2): N(N+1)\/2 intervals with O(1) amortized work each \u2014 about 12,502,500 constant-time updates at N=5000.<\/li>\n<li>Space O(N): the answer array, plus the input.<\/li>\n<li>Measured on this machine (Apple Silicon, CPython 3): the curriculum Python version takes about 17s on the N=5000 random case \u2014 it will <strong>not<\/strong> fit a typical 5-second limit; C++ runs it in about 0.03s with no pressure. Bottom line: use the Python version to learn the algorithm (some judges relax limits for Python or allow PyPy), and <strong>submit C++ in a real contest<\/strong>. Python tuning is constant-factor only (inline compare instead of min(), buffered input \u2014 together roughly the edge of 5s); the algorithm itself is already optimal in its complexity class.<\/li>\n<\/ul>\n<h2>\u5e38\u89c1\u9519\u8bef<\/h2>\n<ol>\n<li>Sorting first \u2014 reordering changes every interval and guarantees a wrong answer.<\/li>\n<li>Forgetting gap centers \u2014 odd lengths come out right while even lengths stay at their initial value.<\/li>\n<li>Initializing ans to 0 \u2014 the min updates never take effect and the output is all zeros.<\/li>\n<li>Recomputing the full asymmetry inside each expansion \u2014 degrades to O(N\u00b3) and times out at full marks.<\/li>\n<li>Prefix-sum splitting on non-monotonic data \u2014 splitting |a\u2212b| needs a known order, which full-mark data does not have.<\/li>\n<li>Output format \u2014 N integers on one line, space-separated; trailing spaces or missing lengths are format errors.<\/li>\n<\/ol>\n<h2>Review Questions<\/h2>\n<ol>\n<li>Why does every interval have exactly one center? Which lengths' optima are missed if gap centers are skipped?<\/li>\n<li>Why is sorting illegal in this problem? Explain it in terms of how an \"interval\" is defined.<\/li>\n<li>The recurrence asym(l, r) = |h_l \u2212 h_r| + asym(l+1, r\u22121) maps to a length-ordered DP \u2014 how is it written, and what do the three rolling rows store?<\/li>\n<li>Why does the non-decreasing subtask allow O(1) asymmetry queries via prefix sums, and what exactly breaks on full-mark data?<\/li>\n<li>If you must submit in Python under a tight limit, what constant-factor optimizations remain, and roughly how much do they save?<\/li>\n<\/ol>\n<\/article>\n<\/div>\n<div class=\"ati-article-content ati-lang-zh\">\n<article class=\"ati-post-article\">\n<p>\u4e00\u6392\u5c71\u7684\u9ad8\u5ea6\u7ed9\u5b9a\u540e\uff0c\u4efb\u53d6\u4e00\u4e2a\u8fde\u7eed\u533a\u95f4\uff08\u88c1\u526a\uff09\uff0c\u628a\u533a\u95f4\u4e24\u7aef\u7b49\u9ad8\u5bf9\u79f0\u4f4d\u7f6e\u7684\u5c71\u4e24\u4e24\u914d\u5bf9\uff0c\u9ad8\u5ea6\u5dee\u4e4b\u548c\u5c31\u662f\u8fd9\u4e2a\u88c1\u526a\u7684\"\u4e0d\u5bf9\u79f0\u503c\"\u3002\u9898\u76ee\u8981\u7684\u4e0d\u662f\u67d0\u4e00\u4e2a\u88c1\u526a\u7684\u7b54\u6848\uff0c\u800c\u662f\uff1a<strong>\u5bf9\u6bcf\u4e2a\u53ef\u80fd\u7684\u957f\u5ea6 1 \u5230 N\uff0c\u6240\u6709\u8be5\u957f\u5ea6\u88c1\u526a\u4e2d\u6700\u5c0f\u7684\u4e0d\u5bf9\u79f0\u503c<\/strong>\u3002CCC 2023 Senior \u7b2c 2 \u9898 Symmetric Mountains \u770b\u8d77\u6765\u8981\u679a\u4e3e\u6d77\u91cf\u533a\u95f4\uff0c\u771f\u6b63\u8003\u7684\u5374\u662f\uff1a\u4f60\u80fd\u4e0d\u80fd\u770b\u51fa\"\u6bcf\u4e2a\u533a\u95f4\u6070\u6709\u4e00\u4e2a\u4e2d\u5fc3\"\uff0c\u628a\u91cd\u590d\u8ba1\u7b97\u6d88\u6389\u3002\u6838\u5fc3\u7b97\u6cd5\u53ea\u6709\u4e00\u4e2a\u2014\u2014\u56fa\u5b9a\u4e2d\u70b9\uff0c\u5411\u5916\u6269\u5c55\u3002<\/p>\n<p><strong>\u914d\u5957\u89c6\u9891\uff1a<\/strong> <a href=\"https:\/\/www.xiaohongshu.com\/discovery\/item\/6ac1c2640000000002028378\">\u5728\u5c0f\u7ea2\u4e66\u89c2\u770b Berny \u8001\u5e08\u8bb2\u89e3\u300a2023 S2 Symmetric Mountains\u300b<\/a><\/p>\n<h2>\u672c\u9898\u5728 CCC DSA \u5730\u56fe\u91cc\u7684\u4f4d\u7f6e<\/h2>\n<ul>\n<li>Level: Senior S2<\/li>\n<li>Pattern: Center Expansion\uff08\u4e2d\u5fc3\u6269\u5c55\uff0c\u5411\u5916\u53cc\u6307\u9488\uff09<\/li>\n<li>Prerequisite: \u6570\u7ec4\u4e0e\u4e0b\u6807\u3001\u5faa\u73af\u3001<code>abs()<\/code>\u3001Big-O \u57fa\u7840\uff08<a href=\"\/zh_cn\/python-syntax-basics-input-operators-conditions\/\">Python \u57fa\u7840\uff1a\u8f93\u5165\u3001\u8fd0\u7b97\u7b26\u4e0e\u6761\u4ef6<\/a>\u3001<a href=\"\/zh_cn\/python-list-append-vs-plus\/\">Python \u5217\u8868\u57fa\u7840<\/a>\uff09<\/li>\n<li>What this teaches: \u628a\"\u6bcf\u4e2a\u533a\u95f4\u6070\u6709\u4e00\u4e2a\u4e2d\u5fc3\"\u7ffb\u8bd1\u6210\u589e\u91cf\u9012\u63a8\uff08\u6bcf\u6269\u4e00\u6b65\u53ea\u52a0\u4e00\u5bf9\uff09\uff0c\u518d\u6309\u957f\u5ea6\u805a\u5408\u6700\u5c0f\u503c\u2014\u2014\u8bc6\u522b\u5e76\u6d88\u53bb\u91cd\u590d\u8ba1\u7b97<\/li>\n<li>Where it appears again: \u56de\u6587\u5224\u5b9a\u4e0e\u6700\u957f\u56de\u6587\u5b50\u4e32\u3001\u53cc\u6307\u9488\/\u6ed1\u7a97\u4e13\u9898 \uff08planned\uff09\u3001CPW-012 Searching for Strings\uff08planned\uff09<\/li>\n<\/ul>\n<h2>\u4e0b\u4e00\u6b65\u63a8\u8350<\/h2>\n<p>\u5982\u679c\u4f60\u5df2\u7ecf\u7406\u89e3\u8fd9\u9053\u9898\uff0c\u53ef\u4ee5\u7ee7\u7eed\u770b\uff1a<\/p>\n<ul>\n<li>\u76f8\u5173 CP Weekly \u771f\u9898\uff1a<a href=\"\/zh_cn\/ccc-2017-s1-sum-game-solution-analysis\/\">CCC 2017 S1 Sum Game \u9898\u89e3<\/a>\uff08\u524d\u7f00\u548c\u4e0e\u533a\u95f4\u548c\uff09\u3001CCC 2020 S3 Searching for Strings\uff08sliding window\uff0ccoming soon\uff09\u3001CCC 2016 J5\/S2 Tandem Bicycle\uff08\u6392\u5e8f\u4e0e\u53cc\u6307\u9488\uff0ccoming soon\uff09<\/li>\n<li>\u76f8\u5173 Python \/ C++ \u57fa\u7840\uff1a<a href=\"\/zh_cn\/python-syntax-basics-input-operators-conditions\/\">Python \u57fa\u7840\uff1a\u8f93\u5165\u3001\u8fd0\u7b97\u7b26\u4e0e\u6761\u4ef6<\/a>\u3001<a href=\"\/zh_cn\/python-list-append-vs-plus\/\">Python \u5217\u8868 append() \u548c + \u7684\u533a\u522b<\/a><\/li>\n<li>\u76f8\u5173 DSA \u4e13\u9898\uff1aPrefix Sum and Sliding Window Patterns\uff08planned\uff09<\/li>\n<\/ul>\n<h2>\u9898\u76ee\u8981\u6211\u4eec\u505a\u4ec0\u4e48<\/h2>\n<p>\u8f93\u5165 N \u5ea7\u5c71\u7684\u9ad8\u5ea6 h\u2081\u2026h\u2099\u3002\u4e00\u4e2a\u88c1\u526a\u662f\u8fde\u7eed\u533a\u95f4 [l, r]\uff0c\u5b83\u7684\u4e0d\u5bf9\u79f0\u503c\u5b9a\u4e49\u4e3a\uff1a\u4ece\u4e24\u7aef\u5411\u4e2d\u95f4\u9010\u5bf9\u6bd4\u8f83\uff0c\u6240\u6709\u5bf9\u79f0\u4f4d\u7f6e\u9ad8\u5ea6\u5dee\u7684\u7edd\u5bf9\u503c\u4e4b\u548c\uff0c\u5373 |h_l \u2212 h_r| + |h_{l+1} \u2212 h_{r\u22121}| + \u2026\u3002<\/p>\n<p>\u8f93\u51fa N \u4e2a\u6574\u6570\uff1a\u7b2c k \u4e2a\u662f<strong>\u6240\u6709\u957f\u5ea6\u4e3a k \u7684\u88c1\u526a\u91cc\uff0c\u4e0d\u5bf9\u79f0\u503c\u7684\u6700\u5c0f\u503c<\/strong>\u3002<\/p>\n<p>\u5b98\u65b9\u6837\u4f8b\uff1aN=7\uff0c\u9ad8\u5ea6 <code>[3 1 4 1 5 9 2]<\/code>\uff0c\u7b54\u6848\u662f <code>0 2 0 5 2 10 10<\/code>\u3002<\/p>\n<p>\u9898\u76ee\u539f\u6587\u89c1 <a href=\"https:\/\/cemc.uwaterloo.ca\/sites\/default\/files\/documents\/2023\/2023CCCSrProblemSet.html\">CEMC 2023 CCC Senior \u5b98\u65b9\u9898\u96c6<\/a>\u3002<\/p>\n<p>\u6570\u636e\u8303\u56f4\uff1a<code>1 \u2264 N \u2264 5000<\/code>\uff0c<code>0 \u2264 h_i \u2264 10^5<\/code>\u3002\u5b50\u4efb\u52a1\u5206\u5c42\uff1aN\u2264300 \u53ef\u76f4\u63a5\u66b4\u529b\uff1b\u4e2d\u95f4\u5b50\u4efb\u52a1\u9ad8\u5ea6\u975e\u9012\u51cf\uff08\u53ef\u7528\u524d\u7f00\u548c\u62c6\u7edd\u5bf9\u503c\uff09\uff1b\u6ee1\u5206\u65e0\u4efb\u4f55\u9644\u52a0\u7ea6\u675f\u2014\u2014\u4e2d\u5fc3\u6269\u5c55\u5bf9\u6240\u6709\u5b50\u4efb\u52a1\u901a\u7528\u3002<\/p>\n<h2>\u521d\u5b66\u8005\u5bb9\u6613\u5361\u5728\u54ea\u91cc<\/h2>\n<ul>\n<li><strong>\u5148\u6392\u5e8f\u518d\u7b97<\/strong>\uff1a\u6392\u5e8f\u8ba9\u7edd\u5bf9\u503c\u597d\u62c6\uff0c\u4f46\u4f1a\u6539\u53d8\u5c71\u7684\u987a\u5e8f\u2014\u2014\u7167\u7247\u88ab\u91cd\u6392\uff0c\u533a\u95f4\u5168\u53d8\u4e86\u3002\u672c\u9898<strong>\u4e25\u7981\u6392\u5e8f<\/strong>\u3002<\/li>\n<li><strong>\u6309\u957f\u5ea6\u76f4\u63a5\u66b4\u529b<\/strong>\uff1a\u5bf9\u6bcf\u4e2a\u957f\u5ea6\u679a\u4e3e\u6240\u6709\u8d77\u70b9\uff0c\u518d\u6574\u4f53\u91cd\u7b97\u4e0d\u5bf9\u79f0\u503c\uff0c\u662f O(N\u00b3)\uff0cN=5000 \u7ea6 10\u00b9\u00b9 \u6b21\u8fd0\u7b97\uff0c\u5fc5\u7136\u8d85\u65f6\u3002<\/li>\n<li><strong>\u6f0f\u6389\u5076\u6570\u4e2d\u5fc3<\/strong>\uff1a\u957f\u5ea6\u4e3a\u5947\u6570\u7684\u88c1\u526a\uff0c\u4e2d\u5fc3\u662f\"\u4e00\u5ea7\u5c71\"\uff1b\u957f\u5ea6\u4e3a\u5076\u6570\u65f6\uff0c\u4e2d\u5fc3\u5728\"\u4e24\u5ea7\u5c71\u4e4b\u95f4\u7684\u7a7a\u9699\"\u3002\u53ea\u5199\u4e00\u79cd\u4e2d\u5fc3\u4f1a\u6f0f\u6389\u4e00\u534a\u533a\u95f4\u3002<\/li>\n<li><strong>\u7b54\u6848\u6570\u7ec4\u521d\u503c\u5199\u6210 0<\/strong>\uff1a\u6bcf\u4e2a\u957f\u5ea6\u8981\u6c42\u7684\u662f\"\u6700\u5c0f\u503c\"\uff0c\u521d\u503c\u5fc5\u987b\u662f\u65e0\u7a77\u5927\uff0c\u518d\u4e0d\u65ad\u53d6 min\u3002<\/li>\n<li><strong>\u5bf9\u975e\u9012\u51cf\u6570\u636e\u5199\u524d\u7f00\u548c\u62c6\u53f7<\/strong>\uff1a\u62c6\u7edd\u5bf9\u503c\u4f9d\u8d56\u5355\u8c03\u6027\uff0c\u6ee1\u5206\u6570\u636e\u6ca1\u6709\u5355\u8c03\u4fdd\u8bc1\uff0c\u6b64\u6cd5\u8fc7\u4e0d\u4e86\u7b2c\u4e09\u4e2a\u5b50\u4efb\u52a1\u3002<\/li>\n<\/ul>\n<h2>\u6838\u5fc3\u7b97\u6cd5\u6982\u5ff5<\/h2>\n<p>\u89c2\u5bdf\u4e00\u4e2a\u88c1\u526a [l, r] \u7684\u4e0d\u5bf9\u79f0\u503c\u5c55\u5f00\u5f0f\uff1a<\/p>\n<pre><code class=\"language-text\">asym(l, r) = |h_l \u2212 h_r| + |h_{l+1} \u2212 h_{r\u22121}| + |h_{l+2} \u2212 h_{r\u22122}| + \u2026<\/code><\/pre>\n<p>\u9664\u4e86\u6700\u5916\u9762\u4e00\u5bf9\uff0c<strong>\u62ec\u53f7\u91cc\u5269\u4e0b\u7684\u6240\u6709\u9879\u6070\u597d\u5c31\u662f asym(l+1, r\u22121)<\/strong>\u3002\u4e8e\u662f\u5f97\u5230\u4e00\u6761\u589e\u91cf\u9012\u63a8\uff1a<\/p>\n<pre><code class=\"language-text\">asym(l, r) = |h_l \u2212 h_r| + asym(l+1, r\u22121)<\/code><\/pre>\n<p>\u7a7a\u533a\u95f4\u548c\u5355\u5ea7\u5c71\u7684\u4e0d\u5bf9\u79f0\u503c\u90fd\u662f 0\u3002\u8fd9\u610f\u5473\u7740\uff1a\u5982\u679c\u6309\"\u56fa\u5b9a\u4e2d\u5fc3\u3001\u5411\u5916\u6269\u5f20\"\u7684\u987a\u5e8f\u751f\u6210\u533a\u95f4\uff0c\u6bcf\u6269\u4e00\u6b65\u53ea\u9700\u8981\u52a0\u4e0a\u65b0\u9732\u51fa\u6765\u7684\u4e00\u5bf9\u9ad8\u5ea6\u5dee\uff0c\u5185\u5c42\u7684\u503c\u5df2\u7ecf\u5728\u7d2f\u52a0\u5668\u91cc\u2014\u2014<strong>\u6ca1\u6709\u4efb\u4f55\u4e00\u5bf9\u88ab\u91cd\u590d\u8ba1\u7b97<\/strong>\u3002<\/p>\n<p>\u800c\u6bcf\u4e2a\u533a\u95f4 [l, r] \u90fd\u6709\u4e14\u4ec5\u6709\u4e00\u4e2a\u4e2d\u5fc3\uff1a\u5947\u6570\u957f\u5ea6\u7684\u4e2d\u5fc3\u662f\u67d0\u4e2a\u4e0b\u6807 c\uff0c\u5076\u6570\u957f\u5ea6\u7684\u4e2d\u5fc3\u662f\u67d0\u4e2a\u7a7a\u9699 (c, c+1)\u3002\u6240\u4ee5\u679a\u4e3e\u5168\u90e8\u4e2d\u5fc3\uff08N \u4e2a\u4f4d\u7f6e\u4e2d\u5fc3 + N\u22121 \u4e2a\u7a7a\u9699\u4e2d\u5fc3\uff09\uff0c\u4ece\u4e2d\u5fc3\u5411\u5916\u6269\u5f20\u5e76\u7ef4\u62a4\u7d2f\u52a0\u5668\uff0c\u5c31\u8986\u76d6\u4e86\u5168\u90e8 N(N+1)\/2 \u4e2a\u533a\u95f4\u3002<\/p>\n<h2>\u72b6\u6001\u5b9a\u4e49<\/h2>\n<ul>\n<li><code>ans[k]<\/code>\uff1a\u957f\u5ea6\u4e3a k \u7684\u88c1\u526a\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\uff08k = 1..N\uff09\uff0c\u521d\u503c\u4e3a \u221e\u3002<\/li>\n<li>\u6269\u5f20\u8fc7\u7a0b\u4e2d\u7684\u77ac\u65f6\u72b6\u6001\uff1a<code>left<\/code>\u3001<code>right<\/code>\u3001<code>cost<\/code>\u2014\u2014\u5f53\u524d\u533a\u95f4\u4e24\u7aef\u4e0b\u6807\u4e0e\u5df2\u7d2f\u52a0\u7684\u4e0d\u5bf9\u79f0\u503c\u3002<\/li>\n<\/ul>\n<p>\u6bcf\u6b21\u6269\u5f20\u5f97\u5230\u4e00\u4e2a\u65b0\u533a\u95f4\uff0c\u5c31\u7528 <code>cost<\/code> \u66f4\u65b0 <code>ans[r \u2212 l + 1]<\/code>\u3002\u4e0d\u9700\u8981\u4fdd\u5b58\u6240\u6709\u533a\u95f4\u672c\u8eab\u3002<\/p>\n<h2>\u7b97\u6cd5\u6b65\u9aa4<\/h2>\n<ol>\n<li>\u8bfb\u5165 N \u548c\u9ad8\u5ea6\u6570\u7ec4 h\u3002<\/li>\n<li><code>ans[1..N]<\/code> \u5168\u90e8\u521d\u59cb\u5316\u4e3a \u221e\u3002<\/li>\n<li>\u5bf9\u6bcf\u4e2a\u4f4d\u7f6e\u4e2d\u5fc3 c\uff080..N\u22121\uff09\uff1a\u4ece l=r=c \u51fa\u53d1\uff0c<code>cost=0<\/code>\uff1b\u6bcf\u6b21\u5148\u52a0\u4e0a |h[l] \u2212 h[r]|\uff0c\u7528 cost \u66f4\u65b0 ans[r\u2212l+1]\uff0c\u7136\u540e l \u5de6\u79fb\u3001r \u53f3\u79fb\uff0c\u76f4\u5230\u8d8a\u754c\u3002<\/li>\n<li>\u5bf9\u6bcf\u4e2a\u7a7a\u9699\u4e2d\u5fc3 c\uff080..N\u22122\uff09\uff1a\u4ece l=c, r=c+1 \u51fa\u53d1\uff0c\u540c\u6837\u6269\u5f20\u5e76\u66f4\u65b0\u3002<\/li>\n<li>\u8f93\u51fa ans[1..N]\uff0c\u7a7a\u683c\u5206\u9694\u3002<\/li>\n<\/ol>\n<h2>\u5b98\u65b9\u6837\u4f8b\u6838\u5bf9<\/h2>\n<p>\u7528\u6837\u4f8b <code>[3 1 4 1 5 9 2]<\/code> \u9010\u957f\u5ea6\u6838\u5bf9\uff08\u7ec4\u53f7\u4ece 0 \u5f00\u59cb\uff09\uff1a<\/p>\n<div class=\"ati-table-wrap\">\n<table>\n<thead>\n<tr>\n<th>\u957f\u5ea6<\/th>\n<th>\u6700\u4f18\u88c1\u526a<\/th>\n<th>\u975e\u5bf9\u79f0\u503c<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>\u4efb\u610f\u4e00\u5ea7\u5c71<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>[3 1]<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>[1 4 1]<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>[3 1 4 1] \u6216 [1 5 9 2]<\/td>\n<td>5<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>[3 1 4 1 5]<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>[1 4 1 5 9 2]<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>\u5168\u90e8\u4e03\u5ea7<\/td>\n<td>10<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\u518d\u4ee5\u4e2d\u5fc3 2\uff08\u9ad8\u5ea6 4 \u90a3\u5ea7\u5c71\uff09\u4e3a\u4f8b\u770b\u589e\u91cf\u8fc7\u7a0b\uff0c\u88c1\u526a [3 1 4 1 5] \u7684\u4ee3\u4ef7\u662f\u8fd9\u6837\u957f\u51fa\u6765\u7684\uff1a\u5148 (4,4) \u52a0 0\uff1b\u6269\u5230 (1,3) \u52a0 |1\u22121|=0\uff1b\u518d\u6269\u5230 (0,4) \u52a0 |3\u22125|=2\u2014\u2014\u603b\u957f 3 \u6b65\uff0c\u6bcf\u6b65\u53ea\u52a0\u4e00\u5bf9\u3002\u5b98\u65b9\u5bf9\u957f\u5ea6 5 \u7684\u4e09\u4e2a\u88c1\u526a\u4ee3\u4ef7\u662f 2\u30019\u300110\uff0c\u53d6\u6700\u5c0f\u5f97 2\uff0c\u4e0e\u8f93\u51fa\u4e00\u81f4\u3002<\/p>\n<h2>Python \u89e3\u6cd5<\/h2>\n<pre><code class=\"language-python\">n = int(input())\nmountains = list(map(int, input().split()))\nanswer = [10**18] * (n + 1)\n\nfor center in range(n):\n    cost = 0\n    left = center\n    right = center\n    while left &gt;= 0 and right &lt; n:\n        cost += abs(mountains[left] - mountains[right])\n        length = right - left + 1\n        answer[length] = min(answer[length], cost)\n        left -= 1\n        right += 1\n\nfor center in range(n - 1):\n    cost = 0\n    left = center\n    right = center + 1\n    while left &gt;= 0 and right &lt; n:\n        cost += abs(mountains[left] - mountains[right])\n        length = right - left + 1\n        answer[length] = min(answer[length], cost)\n        left -= 1\n        right += 1\n\nprint(*answer[1:])<\/code><\/pre>\n<p>\u8981\u70b9\uff1a\u4ee3\u7801\u4e0e\u8bfe\u7a0b\u6559\u6848\uff08p2003 Session 3\uff09\u7684\u53c2\u8003\u5b9e\u73b0\u4e00\u81f4\u2014\u2014\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5404\u5199\u4e00\u4e2a\u6269\u5f20\u5faa\u73af\uff0c<code>mountains \/ center \/ cost \/ answer<\/code> \u5c31\u662f\u8bfe\u5802\u4e0a\u7684\u53d8\u91cf\u540d\uff0c\u5b66\u751f\u53ef\u4ee5\u76f4\u63a5\u5bf9\u7167\u3002\u6ce8\u610f <code>cost<\/code> \u5355\u8c03\u4e0d\u51cf\uff0c\u4f46\u4e0d\u540c\u957f\u5ea6\u7684\u7b54\u6848\u4e92\u4e0d\u5f71\u54cd\uff0c\u4e0d\u80fd\u7528\"\u5df2\u7ecf\u53d8\u5927\u5c31\u526a\u679d\"\u63d0\u524d\u9000\u51fa\u3002<\/p>\n<h2>C++ \u89e3\u6cd5<\/h2>\n<pre><code class=\"language-cpp\">#include &lt;algorithm&gt;\n#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;cstdlib&gt;\nusing namespace std;\n\nint main() {\n    int n;\n    cin &gt;&gt; n;\n    vector&lt;int&gt; mountains(n);\n    for (int&amp; height : mountains) {\n        cin &gt;&gt; height;\n    }\n\n    const long long INF = (1LL &lt;&lt; 60);\n    vector&lt;long long&gt; answer(n + 1, INF);\n\n    for (int center = 0; center &lt; n; center++) {\n        long long cost = 0;\n        int left = center;\n        int right = center;\n        while (left &gt;= 0 &amp;&amp; right &lt; n) {\n            cost += abs(mountains[left] - mountains[right]);\n            int length = right - left + 1;\n            answer[length] = min(answer[length], cost);\n            left--;\n            right++;\n        }\n    }\n\n    for (int center = 0; center + 1 &lt; n; center++) {\n        long long cost = 0;\n        int left = center;\n        int right = center + 1;\n        while (left &gt;= 0 &amp;&amp; right &lt; n) {\n            cost += abs(mountains[left] - mountains[right]);\n            int length = right - left + 1;\n            answer[length] = min(answer[length], cost);\n            left--;\n            right++;\n        }\n    }\n\n    for (int length = 1; length &lt;= n; length++) {\n        if (length &gt; 1) {\n            cout &lt;&lt; &#x27; &#x27;;\n        }\n        cout &lt;&lt; answer[length];\n    }\n    cout &lt;&lt; &#x27;\\n&#x27;;\n    return 0;\n}<\/code><\/pre>\n<p>\u8981\u70b9\uff1a\u4e0e\u6559\u6848\u53c2\u8003\u5b9e\u73b0\u4e00\u81f4\uff1b<code>long long<\/code> \u9632\u6b62\u7d2f\u52a0\u6ea2\u51fa\uff08\u6700\u574f\u7ea6 \u230aN\/2\u230b\u00d710\u2075\uff09\uff1b<code>answer<\/code> \u521d\u503c\u4e3a <code>(1LL &lt;&lt; 60)<\/code> \u7ea7\u522b\u7684\u65e0\u7a77\u5927\uff1b\u4e24\u4e2a\u5faa\u73af\u7ed3\u6784\u5b8c\u5168\u5bf9\u79f0\uff0c\u53ea\u662f\u521d\u59cb (left, right) \u4e0d\u540c\u3002<\/p>\n<h2>\u6b63\u786e\u6027\u8bf4\u660e<\/h2>\n<ul>\n<li><strong>\u6bcf\u4e2a\u533a\u95f4\u88ab\u6070\u597d\u8bbf\u95ee\u4e00\u6b21<\/strong>\uff1a\u4efb\u610f\u533a\u95f4 [l, r] \u7684\u4e2d\u70b9\u552f\u4e00\uff08\u4f4d\u7f6e\u6216\u7a7a\u9699\uff09\uff0c\u6269\u5f20\u4ece\u8be5\u4e2d\u5fc3\u51fa\u53d1\u5fc5\u7ecf [l, r]\uff0c\u4e14\u4e0d\u540c\u4e2d\u5fc3\u751f\u6210\u7684\u533a\u95f4\u96c6\u5408\u4e0d\u76f8\u4ea4\u3002<\/li>\n<li><strong>\u6bcf\u6b21\u66f4\u65b0\u7684 cost \u662f\u6b63\u786e\u7684 asym(l, r)<\/strong>\uff1a\u5bf9\u6269\u5f20\u534a\u5f84\u5f52\u7eb3\u3002\u534a\u5f84 0\uff08\u6216\u7a7a\u9699\u521d\u6001\uff09\u65f6\u533a\u95f4\u957f\u5ea6\u4e3a 1\uff08\u6216 2\uff09\uff0ccost \u521d\u503c 0 \u52a0\u4e0a\u9996\u5bf9\u9ad8\u5ea6\u5dee\uff0c\u6b63\u786e\uff1b\u8bbe\u5185\u5c42 [l+1, r\u22121] \u7684\u7d2f\u52a0\u503c\u6b63\u786e\uff0c\u5219\u6269\u5230 [l, r] \u65f6\u65b0\u589e\u7684\u6070\u597d\u662f\u6700\u5916\u4e00\u5bf9 |h_l \u2212 h_r|\uff0c\u7531\u9012\u63a8\u5f0f asym(l, r) = |h_l \u2212 h_r| + asym(l+1, r\u22121) \u5373\u5f97\u6b63\u786e\u3002<\/li>\n<li><strong>ans[k] \u6700\u7ec8\u662f\u6240\u6709\u957f\u5ea6\u4e3a k \u7684\u533a\u95f4\u7684\u6700\u5c0f\u503c<\/strong>\uff1a\u957f\u5ea6\u4e3a k \u7684\u6bcf\u4e2a\u533a\u95f4\u90fd\u5728\u5176\u4e2d\u5fc3\u6269\u5f20\u65f6\u88ab\u8ba1\u7b97\u5e76\u53c2\u4e0e\u53d6 min\uff0c\u65e0\u9057\u6f0f\u3001\u65e0\u91cd\u590d\u3002<\/li>\n<\/ul>\n<p>\u56e0\u6b64\u8f93\u51fa\u5c31\u662f\u9898\u76ee\u6240\u6c42\u7684\u6bcf\u4e2a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002<\/p>\n<h2>\u590d\u6742\u5ea6\u5206\u6790<\/h2>\n<ul>\n<li>\u65f6\u95f4 O(N\u00b2)\uff1aN(N+1)\/2 \u4e2a\u533a\u95f4\uff0c\u6bcf\u4e2a\u533a\u95f4\u644a\u8fd8 O(1) \u6b21\u66f4\u65b0\u3002N=5000 \u65f6\u7ea6 12,502,500 \u6b21\u5e38\u6570\u66f4\u65b0\u3002<\/li>\n<li>\u7a7a\u95f4 O(N)\uff1a\u7b54\u6848\u6570\u7ec4\uff08\u5916\u52a0\u8f93\u5165\u6570\u7ec4\uff09\u3002<\/li>\n<li>\u5b9e\u6d4b\u53c2\u8003\uff08\u672c\u673a M \u7cfb\u5217\u3001CPython 3\uff09\uff1a\u6559\u6848\u539f\u7248 Python \u5728 N=5000 \u968f\u673a\u6570\u636e\u4e0a\u7ea6 17s\uff0c<strong>\u65e0\u6cd5<\/strong>\u901a\u8fc7\u5e38\u89c1 5s \u65f6\u9650\uff1bC++ \u7ea6 0.03s \u6beb\u65e0\u538b\u529b\u3002\u7ed3\u8bba\uff1aPython \u7248\u7528\u4e8e\u5b66\u4e60\u7b97\u6cd5\u672c\u8eab\uff08\u90e8\u5206\u8bc4\u6d4b\u673a\u5bf9 Python \u653e\u5bbd\u65f6\u9650\u6216\u53ef\u7528 PyPy\uff09\uff0c<strong>\u6b63\u5f0f\u7ade\u8d5b\u8bf7\u63d0\u4ea4 C++<\/strong>\u3002\u60f3\u4f18\u5316 Python \u53ea\u80fd\u5728\u5e38\u6570\u5c42\u9762\u4e0b\u529f\u592b\uff08\u5982\u5185\u8054\u6bd4\u8f83\u4ee3\u66ff min()\u3001buffer \u8bfb\u5165\u7ea6\u53ef\u538b\u5230 5s \u8fb9\u7f18\uff09\uff0c\u7b97\u6cd5\u672c\u8eab\u5df2\u5230\u6700\u4f18\u6e10\u8fdb\u9636\u3002<\/li>\n<\/ul>\n<h2>\u5e38\u89c1\u9519\u8bef<\/h2>\n<ol>\n<li><strong>\u5148\u6392\u5e8f\u518d\u505a<\/strong>\uff1a\u6539\u53d8\u5c71\u7684\u76f8\u5bf9\u987a\u5e8f\uff0c\u533a\u95f4\u96c6\u5408\u5168\u53d8\uff0c\u7b54\u6848\u5fc5\u9519\u3002<\/li>\n<li><strong>\u6f0f\u6389\u7a7a\u9699\u4e2d\u5fc3<\/strong>\uff1a\u53ea\u6709\u5947\u6570\u957f\u5ea6\u7684\u7b54\u6848\u662f\u5bf9\u7684\uff0c\u5076\u6570\u957f\u5ea6\u4ecd\u662f\u65e0\u7a77\u5927\u6216\u521d\u59cb\u503c\u3002<\/li>\n<li><strong>ans \u521d\u503c\u5199\u6210 0<\/strong>\uff1amin \u66f4\u65b0\u6c38\u8fdc\u5931\u6548\uff0c\u8f93\u51fa\u5168 0\u3002<\/li>\n<li><strong>\u6269\u5f20\u65f6\u6574\u4f53\u91cd\u7b97\u4e0d\u5bf9\u79f0\u503c<\/strong>\uff1a\u9000\u5316\u6210 O(N\u00b3)\uff0c\u6ee1\u5206\u5fc5\u8d85\u65f6\u3002<\/li>\n<li><strong>\u7528\u975e\u9012\u51cf\u4e13\u5c5e\u7684\u524d\u7f00\u548c\u62c6\u53f7<\/strong>\uff1a\u62c6 |a\u2212b| \u9700\u8981\u77e5\u9053\u5927\u5c0f\u5173\u7cfb\uff0c\u6ee1\u5206\u6570\u636e\u4e0d\u6ee1\u8db3\u5355\u8c03\u6027\u3002<\/li>\n<li><strong>\u8f93\u51fa\u683c\u5f0f<\/strong>\uff1aN \u4e2a\u6574\u6570\u4e00\u884c\u3001\u7a7a\u683c\u5206\u9694\uff1b\u884c\u672b\u591a\u7a7a\u683c\u3001\u6f0f\u957f\u5ea6\u90fd\u662f\u683c\u5f0f\u9519\u8bef\u3002<\/li>\n<\/ol>\n<h2>\u590d\u4e60\u95ee\u9898<\/h2>\n<ol>\n<li>\u4e3a\u4ec0\u4e48\u6bcf\u4e2a\u533a\u95f4\u6070\u6709\u4e00\u4e2a\u4e2d\u5fc3\uff1f\u6f0f\u6389\u7a7a\u9699\u4e2d\u5fc3\u4f1a miss \u54ea\u4e9b\u957f\u5ea6\u7684\u6700\u4f18\u89e3\uff1f<\/li>\n<li>\u4e3a\u4ec0\u4e48\u6392\u5e8f\u5728\u8fd9\u9053\u9898\u91cc\u662f\u975e\u6cd5\u64cd\u4f5c\uff1f\u4ece\"\u533a\u95f4\"\u7684\u5b9a\u4e49\u89d2\u5ea6\u89e3\u91ca\u3002<\/li>\n<li>\u9012\u63a8\u5f0f asym(l, r) = |h_l \u2212 h_r| + asym(l+1, r\u22121) \u5bf9\u5e94\u7684\"\u6309\u957f\u5ea6\u9012\u63a8\"DP \u600e\u4e48\u5199\uff1f\u5b83\u540c\u6837\u9700\u8981 O(N) \u989d\u5916\u7a7a\u95f4\uff0c\u6eda\u52a8\u6570\u7ec4\u7684\u4e09\u884c\u5206\u522b\u4fdd\u5b58\u4ec0\u4e48\uff1f<\/li>\n<li>\u975e\u9012\u51cf\u5b50\u4efb\u52a1\u4e3a\u4ec0\u4e48\u80fd\u7528\u524d\u7f00\u548c\u505a\u5230 O(1) \u67e5\u8be2\u4e00\u4e2a\u533a\u95f4\u7684\u4e0d\u5bf9\u79f0\u503c\uff1f\u8fd9\u4e2a\u6280\u5de7\u5728\u6ee1\u5206\u6570\u636e\u4e0a\u5931\u6548\u7684\u786e\u5207\u539f\u56e0\u662f\u4ec0\u4e48\uff1f<\/li>\n<li>\u5982\u679c\u4f60\u53ea\u80fd\u7528 Python \u63d0\u4ea4\u4e14\u8bc4\u6d4b\u65f6\u9650\u5f88\u7d27\uff0c\u9664\u4e86\u6362\u8bed\u8a00\u8fd8\u6709\u54ea\u4e9b\u5e38\u6570\u5c42\u9762\u7684\u4f18\u5316\uff1f\u5404\u81ea\u80fd\u7701\u591a\u5c11\uff1f<\/li>\n<\/ol>\n<\/article>\n<\/div>\n<section class=\"ati-feedback-cta ati-lang-en\" data-ati-feedback>\n<div class=\"ati-feedback-copy\">\n<p class=\"ati-feedback-title\">\u6709\u95ee\u9898\u6216\u5efa\u8bae\uff1f<\/p>\n<p class=\"ati-feedback-note\">\u5982\u679c\u4f60\u5bf9\u672c\u6587\u6709\u7591\u95ee\uff0c\u6216\u5e0c\u671b\u63d0\u51fa\u6539\u8fdb\u5efa\u8bae\uff0c\u8bf7\u7ed9\u6211\u4eec\u53d1\u9001\u79c1\u5bc6\u7559\u8a00\u3002<\/p>\n<\/div>\n<p>  <a class=\"ati-feedback-button\" href=\"\/zh_cn\/contact\/\" data-ati-feedback-link>\u53d1\u9001\u53cd\u9988<\/a><br>\n<\/p><\/section>\n<section class=\"ati-feedback-cta ati-lang-zh\" data-ati-feedback>\n<div class=\"ati-feedback-copy\">\n<p class=\"ati-feedback-title\">\u6709\u95ee\u9898\u6216\u5efa\u8bae\uff1f<\/p>\n<p class=\"ati-feedback-note\">\u5982\u679c\u4f60\u5bf9\u672c\u6587\u6709\u7591\u95ee\uff0c\u6216\u5e0c\u671b\u63d0\u51fa\u6539\u8fdb\u5efa\u8bae\uff0c\u8bf7\u7ed9\u6211\u4eec\u53d1\u9001\u79c1\u5bc6\u7559\u8a00\u3002<\/p>\n<\/div>\n<p>  <a class=\"ati-feedback-button\" href=\"\/zh_cn\/contact\/\" data-ati-feedback-link>\u53d1\u9001\u53cd\u9988<\/a><br>\n<\/p><\/section>\n<div class=\"ati-article-back ati-lang-en\">\n  <a href=\"\/zh_cn\/cp-weekly-challenge\/\">Back to CP Weekly Challenge<\/a>\n<\/div>\n<div class=\"ati-article-back ati-lang-zh\">\n  <a href=\"\/zh_cn\/cp-weekly-challenge\/\">\u8fd4\u56de CP \u6bcf\u5468\u7f16\u7a0b\u6311\u6218<\/a>\n<\/div>\n<\/article>\n<\/section>\n<p>    <\/p>\n<footer class=\"ati-footer\">\n      <a class=\"ati-brand ati-logo\" href=\"\/zh_cn\/\" aria-label=\"Accel Thinking home\"><img loading=\"lazy\" decoding=\"async\" height=\"63\" width=\"366\" src=\"https:\/\/i0.wp.com\/accelthinking.com\/wp-content\/uploads\/2026\/06\/logo-dark-cropped-51.png?w=480&amp;quality=85&amp;ssl=1\" alt=\"Accel Thinking\"><\/a>\n<nav><a class=\"\" href=\"\/zh_cn\/\">\u9996\u9875<\/a><a class=\"\" href=\"\/zh_cn\/northstar\/\">\u5317\u6781\u661f<\/a><a class=\"\" href=\"\/zh_cn\/learning\/\">\u5b66\u4e60\u8def\u5f84<\/a><a class=\"active\" href=\"\/zh_cn\/resources\/\">\u8d44\u6e90\u6587\u7ae0<\/a><a class=\"\" href=\"\/zh_cn\/about\/\">\u5173\u4e8e\u6211\u4eec<\/a><a class=\"\" href=\"\/zh_cn\/contact\/\">\u8054\u7cfb\u6211\u4eec<\/a><a class=\"\" href=\"\/zh_cn\/privacy-policy\/\">\u9690\u79c1\u653f\u7b56<\/a><a class=\"\" href=\"\/zh_cn\/terms-and-conditions\/\">\u6761\u6b3e\u4e0e\u6761\u4ef6<\/a><\/nav>\n<address><a href=\"mailto:info@accelthinking.com\">info@accelthinking.com<\/a><a href=\"tel:+18556265066\">Toll-free: 1-855-626-5066<\/a><span>\u52a0\u62ff\u5927\u5b89\u5927\u7565\u7701\u5965\u514b\u7ef4\u5c14<\/span><\/address>\n<\/footer><\/div>\n<p><\/p>\n<style data-source=\"ati_article_share_tools\">\n.ati-share-tools{margin:0 0 30px!important;padding:20px;background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px}\n.ati-share-tools p{margin:0!important}\n.ati-share-tools .ati-share-kicker{color:#b47c00!important;font-size:13px!important;font-weight:900!important;text-transform:uppercase;letter-spacing:.08em}\n.ati-share-note{margin-top:6px!important;color:#475569!important;font-size:15px!important;line-height:1.45!important}\n.ati-share-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:16px}\n.ati-share-actions button,.ati-share-actions a{display:inline-flex;align-items:center;justify-content:center;min-height:38px;padding:0 13px;border:1px solid #cbd5e1;border-radius:8px;background:#fff;color:#0f172a!important;font:inherit;font-size:13px;font-weight:900;line-height:1;cursor:pointer;text-decoration:none!important}\n.ati-share-actions button:hover,.ati-share-actions a:hover{border-color:#ffc400;background:#fff7d6}\n.ati-share-actions [data-share-copy-link],.ati-share-actions [data-share-native]{background:#ffc400;border-color:#ffc400;color:#050505!important}\n.ati-share-qr{display:flex;gap:14px;align-items:center;margin-top:16px;padding:14px;background:#fff;border:1px solid #e2e8f0;border-radius:8px}\n.ati-share-qr[hidden]{display:none!important}.ati-share-qr img{width:118px;height:118px;border-radius:6px}.ati-share-qr p{color:#475569!important;font-size:14px!important;line-height:1.4!important}\n.ati-share-status{min-height:18px;margin-top:10px!important;color:#0f766e!important;font-size:13px!important;font-weight:800!important}\n@media(max-width:640px){.ati-share-actions button,.ati-share-actions a{width:100%}.ati-share-qr{align-items:flex-start}.ati-share-qr img{width:104px;height:104px}}\n<\/style>\n<p><script data-source=\"ati_article_share_tools\">\n(function(){\n  function text(isZh, en, zh){ return isZh ? zh : en; }\n  function copyText(value, status, message){\n    function done(){ if(status) status.textContent = message; }\n    function fallback(){\n      var input = document.createElement('textarea');\n      input.value = value;\n      input.setAttribute('readonly', '');\n      input.style.position = 'fixed';\n      input.style.left = '-9999px';\n      document.body.appendChild(input);\n      input.select();\n      try { document.execCommand('copy'); } catch(e) {}\n      document.body.removeChild(input);\n      done();\n    }\n    if (navigator.clipboard && navigator.clipboard.writeText) {\n      navigator.clipboard.writeText(value).then(done).catch(fallback);\n    } else fallback();\n  }\n  document.querySelectorAll('[data-ati-share]').forEach(function(box){\n    if (box.dataset.ready) return;\n    box.dataset.ready = '1';\n    var isZh = location.pathname.toLowerCase().includes('\/zh_cn\/');\n    var pageUrl = location.origin + location.pathname;\n    var title = (document.querySelector('.ati-hero h1') || document.querySelector('h1'))?.innerText.trim() || document.title.replace(\/\\s+-\\s+.*$\/, '');\n    var status = box.querySelector('[data-share-status]');\n    var note = box.querySelector('.ati-share-note');\n    var kicker = box.querySelector('.ati-share-kicker');\n    var qrText = box.querySelector('.ati-share-qr p');\n    if (isZh) {\n      kicker.textContent = '\u5206\u4eab\u8fd9\u7bc7\u6587\u7ae0';\n      note.textContent = '\u590d\u5236\u94fe\u63a5\u3001\u8c03\u7528\u624b\u673a\u5206\u4eab\u9762\u677f\u3001\u7528\u5fae\u4fe1\u626b\u7801\uff0c\u6216\u901a\u8fc7\u90ae\u4ef6\u53d1\u9001\u3002';\n      qrText.textContent = '\u7528\u5fae\u4fe1\u626b\u7801\u540e\uff0c\u53ef\u5c06\u6587\u7ae0\u94fe\u63a5\u8f6c\u53d1\u7ed9\u597d\u53cb\u6216\u7fa4\u804a\u3002';\n    }\n    var labels = {\n      '[data-share-native]': text(isZh, 'Share', '\u7cfb\u7edf\u5206\u4eab'),\n      '[data-share-copy-link]': text(isZh, 'Copy Link', '\u590d\u5236\u94fe\u63a5'),\n      '[data-share-wechat]': text(isZh, 'WeChat QR', '\u5fae\u4fe1\u4e8c\u7ef4\u7801')\n    };\n    Object.keys(labels).forEach(function(sel){ var el = box.querySelector(sel); if(el) el.textContent = labels[sel]; });\n    var email = box.querySelector('[data-share-email]');\n    if (email) email.href = 'mailto:?subject=' + encodeURIComponent(title) + '&body=' + encodeURIComponent(title + '\\n\\n' + pageUrl);\n    var qrImg = box.querySelector('[data-share-qr-img]');\n    if (qrImg) qrImg.src = 'https:\/\/api.qrserver.com\/v1\/create-qr-code\/?size=180x180&data=' + encodeURIComponent(pageUrl);\n    var nativeBtn = box.querySelector('[data-share-native]');\n    if (nativeBtn) nativeBtn.addEventListener('click', function(){\n      if (navigator.share) {\n        navigator.share({title:title, url:pageUrl}).catch(function(){});\n      } else {\n        copyText(pageUrl, status, text(isZh, 'Link copied. You can paste it into any app.', '\u94fe\u63a5\u5df2\u590d\u5236\uff0c\u53ef\u7c98\u8d34\u5230\u4efb\u610f\u5e94\u7528\u3002'));\n      }\n    });\n    var copyBtn = box.querySelector('[data-share-copy-link]');\n    if (copyBtn) copyBtn.addEventListener('click', function(){\n      copyText(pageUrl, status, text(isZh, 'Link copied.', '\u94fe\u63a5\u5df2\u590d\u5236\u3002'));\n    });\n    var qrBtn = box.querySelector('[data-share-wechat]');\n    if (qrBtn) qrBtn.addEventListener('click', function(){\n      var qr = box.querySelector('[data-share-qr]');\n      if (qr) qr.hidden = !qr.hidden;\n    });\n  });\n})();\n<\/script><\/p>\n<style data-source=\"ati_ccc_2023_s2_symmetric_mountains_article_assets\">\n.entry-content>p:has(>script){display:none!important;height:0!important;margin:0!important;padding:0!important;overflow:hidden!important;line-height:0!important}\n.ati-lang-zh{display:none!important}\nhtml[lang^=\"zh\"] .ati-lang-en,body.translatepress-zh_CN .ati-lang-en{display:none!important}\nhtml[lang^=\"zh\"] .ati-lang-zh,body.translatepress-zh_CN .ati-lang-zh{display:block!important}\nhtml[lang^=\"zh\"] section.ati-lang-zh,body.translatepress-zh_CN section.ati-lang-zh{display:grid!important}\nhtml[lang^=\"zh\"] .ati-feedback-cta.ati-lang-zh,body.translatepress-zh_CN .ati-feedback-cta.ati-lang-zh{display:flex!important}\n.ati-page .ati-hero{line-height:1.5!important}\n.ati-page .ati-hero .ati-label{line-height:1.3!important}\n.ati-page .ati-hero>div>p:not(.ati-label){line-height:1.55!important}\n.ati-page .ati-hero .ati-article-meta,.ati-page .ati-hero .ati-article-meta span{line-height:1.4!important}\n.ati-page .ati-hero .ati-side,.ati-page .ati-hero .ati-side strong,.ati-page .ati-hero .ati-side p{line-height:1.4!important}\n.ati-page .ati-share-tools,.ati-page .ati-share-tools *{line-height:1.4!important}\n.ati-post-article pre{margin:18px 0 24px!important;padding:18px 20px!important;overflow:auto;border:1px solid #263244;border-radius:8px;background:#0f172a!important;color:#e5e7eb!important;font-size:14px!important;line-height:1.55!important}\n.ati-post-article pre code{display:block;padding:0!important;background:transparent!important;color:inherit!important;white-space:pre!important}\n.ati-post-article code{padding:.14em .34em;border-radius:4px;background:#eef2f7;color:#0f172a;font-size:.92em}\n.ati-post-article h3{margin:30px 0 12px!important;color:#0f172a!important;font-size:23px!important;font-weight:900!important;line-height:1.25!important}\n.ati-post-article ul,.ati-post-article ol{margin:12px 0 22px!important;padding-left:24px!important;color:#334155}\n.ati-post-article li{margin:8px 0!important;line-height:1.65!important}\n.ati-post-article .ati-table-wrap{margin:18px 0 26px;overflow-x:auto;border:1px solid #e2e8f0;border-radius:8px;background:#fff}\n.ati-post-article table{width:100%;border-collapse:collapse;color:#334155;font-size:14px;line-height:1.45}\n.ati-post-article th{background:#f8fafc;color:#0f172a;font-weight:900;text-align:left}\n.ati-post-article th,.ati-post-article td{padding:11px 13px;border-bottom:1px solid #e2e8f0;vertical-align:top}\n.ati-post-article tr:last-child td{border-bottom:0}\n.ati-feedback-cta{display:flex;align-items:center;justify-content:space-between;gap:24px;margin:34px 0 24px;padding:22px 24px;border:1px solid #e2e8f0;border-left:4px solid #ffc400;border-radius:8px;background:#f8fafc}\n.ati-feedback-copy{min-width:0}\n.ati-feedback-cta p{margin:0!important}\n.ati-feedback-title{color:#0f172a!important;font-size:20px!important;font-weight:900!important;line-height:1.25!important}\n.ati-feedback-note{max-width:650px;margin-top:7px!important;color:#475569!important;font-size:15px!important;line-height:1.55!important}\n.ati-feedback-button{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;min-height:44px;padding:0 18px;border:1px solid #ffc400;border-radius:7px;background:#ffc400;color:#050505!important;font-size:14px;font-weight:900;text-decoration:none!important;white-space:nowrap;transition:background .18s ease,border-color .18s ease,transform .18s ease}\n.ati-feedback-button:hover{border-color:#d69e00;background:#ffd84d;transform:translateY(-1px)}\n@media(max-width:700px){.ati-feedback-cta{align-items:stretch;flex-direction:column;padding:20px}.ati-feedback-button{width:100%}}\n<\/style>\n<p><script data-source=\"ati_ccc_2022_j4_s2_group_work_zh_20260930\">\n(function(){\n  if (location.pathname.indexOf('\/zh_cn\/') === -1) return;\n  document.title = \"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\uff0cO(N\u00b2) \u6c42\u6bcf\u4e2a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c | \u52a0\u901f\u5ea6\u601d\u7ef4\";\n  document.querySelectorAll('.entry-title').forEach(function(el) { el.textContent = \"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\uff0cO(N\u00b2) \u6c42\u6bcf\u4e2a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\"; });\n})();\n<\/script><script data-source=\"ati_article_feedback_cta\">\n(function(){\n  var cta = document.querySelector('[data-ati-feedback]');\n  if (!cta) return;\n  var isZh = location.pathname.indexOf('\/zh_cn\/') !== -1;\n  var contactPath = isZh ? '\/zh_cn\/contact\/' : '\/contact\/';\n  var articleTitle = (document.querySelector('.entry-title') || document.querySelector('.ati-hero h1') || {}).textContent || document.title || '';\n  var link = cta.querySelector('[data-ati-feedback-link]');\n  if (link) {\n    link.href = contactPath + '?ati_source=article&article_title=' + encodeURIComponent(articleTitle.trim()) + '&article_url=' + encodeURIComponent(location.href.split('#')[0]) + '#wpforms-form-76';\n  }\n})();\n<\/script><\/p>\n<p><script data-source=\"ati_strategy_phase1_nav_20260712\">\n(function(){\n  var base = 'https:\/\/accelthinking.com';\n  var isZh = location.pathname.toLowerCase().includes('\/zh_cn\/');\n  var t = {\"Home\": \"\u9996\u9875\", \"NorthStar\": \"\u5317\u6781\u661f\u6d4b\u8bc4\", \"Learning\": \"\u5b66\u4e60\u8def\u5f84\", \"Resources\": \"\u8d44\u6e90\u6587\u7ae0\", \"About\": \"\u5173\u4e8e\u6211\u4eec\", \"Contact\": \"\u8054\u7cfb\u6211\u4eec\", \"Start NorthStar\": \"\u5f00\u59cb\u5317\u6781\u661f\u6d4b\u8bc4\", \"Privacy Policy\": \"\u9690\u79c1\u653f\u7b56\", \"Terms & Conditions\": \"\u6761\u6b3e\u4e0e\u6761\u4ef6\", \"Close\": \"\u5173\u95ed\"};\n  var path = location.pathname.toLowerCase();\n  if (path.slice(-1) !== '\/') path += '\/';\n  var basePath = new URL(base).pathname.toLowerCase();\n  if (!basePath || basePath === '\/') basePath = '\/';\n  else basePath = basePath.replace(\/\\\/?$\/, '\/');\n  var zhHomePath = basePath === '\/' ? '\/zh_cn\/' : basePath + 'zh_cn\/';\n  function item(label, href, key) {\n    var active = false;\n    if (key === 'home') active = path === basePath || path === zhHomePath;\n    if (key !== 'home') active = path.indexOf('\/' + key + '\/') !== -1;\n    if (key === 'northstar') {\n      active = active || path.indexOf('\/northstar-quick-assessment\/') !== -1 || path.indexOf('\/northstar-assessment\/') !== -1 || path.indexOf('\/northstar-report\/') !== -1;\n    }\n    if (key === 'learning') {\n      active = active || path.indexOf('\/cp-academy\/') !== -1 || path.indexOf('\/python-programming-pathway\/') !== -1 || path.indexOf('\/ai-literacy\/') !== -1 || path.indexOf('\/python-assessment\/') !== -1;\n    }\n    if (key === 'resources') {\n      active = active || path.indexOf('\/resources\/') !== -1 || document.body.classList.contains('single-post');\n    }\n    return '<a class=\"' + (active ? 'active' : '') + '\" href=\"' + href + '\">' + (isZh ? (t[label] || label) : label) + '<\/a>';\n  }\n  function primary() {\n    return [\n      item('Home', base + '\/', 'home'),\n      item('NorthStar', base + '\/northstar\/', 'northstar'),\n      item('Learning', base + '\/learning\/', 'learning'),\n      item('Resources', base + '\/resources\/', 'resources'),\n      item('About', base + '\/about\/', 'about'),\n      item('Contact', base + '\/contact\/', 'contact')\n    ].join('');\n  }\n  function mobile() {\n    return primary() + '<a class=\"ati-mobile-cta\" href=\"' + base + '\/northstar\/\">' + (isZh ? t['Start NorthStar'] : 'Start NorthStar') + '<\/a><a class=\"ati-mobile-close\" href=\"#\">' + (isZh ? t.Close : 'Close') + '<\/a>';\n  }\n  document.querySelectorAll('.ati-nav,.ns-nav').forEach(function(nav) { nav.innerHTML = primary(); });\n  document.querySelectorAll('.ati-mobile-panel,.ati-mobile-nav-panel').forEach(function(nav) { nav.innerHTML = mobile(); });\n  document.querySelectorAll('.ati-footer nav,.ns-footer nav').forEach(function(nav) {\n    nav.innerHTML = primary() + item('Privacy Policy', base + '\/privacy-policy\/', 'privacy-policy') + item('Terms & Conditions', base + '\/terms-and-conditions\/', 'terms-and-conditions');\n  });\n  document.querySelectorAll('.ati-footer address,.ns-footer address').forEach(function(address) {\n    address.innerHTML = '<a href=\"mailto:info@accelthinking.com\">info@accelthinking.com<\/a><a href=\"tel:+18556265066\">' + (isZh ? '\u514d\u8d39\u7535\u8bdd\uff1a1-855-626-5066' : 'Toll-free: 1-855-626-5066') + '<\/a><span>' + (isZh ? '\u52a0\u62ff\u5927\u5b89\u5927\u7565\u7701\u5965\u514b\u7ef4\u5c14' : 'Oakville, Ontario, Canada') + '<\/span>';\n  });\n  document.querySelectorAll('.ati-header-cta,.ns-header-cta').forEach(function(a) {\n    a.href = base + '\/northstar\/';\n    a.textContent = isZh ? t['Start NorthStar'] : 'Start NorthStar';\n  });\n})();\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fix each odd or even center, expand outward, and find the minimum asymmetry for every crop length in O(N\u00b2).<\/p>","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[7],"tags":[42,60,62,43,64,47,61,63],"class_list":["post-1916","post","type-post","status-publish","format-standard","hentry","category-cp-weekly-challenge","tag-c","tag-ccc-2023-s2","tag-center-expansion","tag-competitive-programming","tag-palindrome","tag-python","tag-symmetric-mountains","tag-two-pointers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55<\/title>\n<meta name=\"description\" content=\"\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\" \/>\n<meta property=\"og:description\" content=\"\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/\" \/>\n<meta property=\"og:site_name\" content=\"Accel Thinking\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-03T12:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-10T03:29:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/accelthinking.com\/wp-content\/plugins\/accel-analytics\/assets\/accel-thinking-og.png\" \/>\n<meta name=\"author\" content=\"ATI Builder\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\" \/>\n<meta name=\"twitter:description\" content=\"\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/accelthinking.com\/wp-content\/plugins\/accel-analytics\/assets\/accel-thinking-og.png\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ATI Builder\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/accelthinking.com\\\/zh_cn\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/accelthinking.com\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/\"},\"author\":{\"name\":\"ATI Builder\",\"@id\":\"https:\\\/\\\/accelthinking.com\\\/#\\\/schema\\\/person\\\/bb7b104098a9c6c91f4fe54c4ab4a348\"},\"headline\":\"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\",\"datePublished\":\"2026-10-03T12:00:00+00:00\",\"dateModified\":\"2026-10-10T03:29:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/accelthinking.com\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/\"},\"wordCount\":1856,\"image\":{\"@id\":\"https:\\\/\\\/accelthinking.com\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/accelthinking.com\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/logo-dark-cropped-51.png\",\"keywords\":[\"C++\",\"CCC 2023 S2\",\"Center Expansion\",\"Competitive Programming\",\"Palindrome\",\"Python\",\"Symmetric Mountains\",\"Two Pointers\"],\"articleSection\":[\"CP Weekly Challenge\"],\"inLanguage\":\"zh-CN\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/accelthinking.com\\\/zh_cn\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/\",\"url\":\"https:\\\/\\\/accelthinking.com\\\/zh_cn\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/\",\"name\":\"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/accelthinking.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/accelthinking.com\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/accelthinking.com\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/accelthinking.com\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/logo-dark-cropped-51.png\",\"datePublished\":\"2026-10-03T12:00:00+00:00\",\"dateModified\":\"2026-10-10T03:29:08+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/accelthinking.com\\\/#\\\/schema\\\/person\\\/bb7b104098a9c6c91f4fe54c4ab4a348\"},\"description\":\"\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/accelthinking.com\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/#breadcrumb\"},\"inLanguage\":\"zh-CN\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/accelthinking.com\\\/zh_cn\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-CN\",\"@id\":\"https:\\\/\\\/accelthinking.com\\\/zh_cn\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/#primaryimage\",\"url\":\"https:\\\/\\\/accelthinking.com\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/logo-dark-cropped-51.png\",\"contentUrl\":\"https:\\\/\\\/accelthinking.com\\\/wp-content\\\/uploads\\\/2026\\\/06\\\/logo-dark-cropped-51.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/accelthinking.com\\\/zh_cn\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/accelthinking.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55\",\"item\":\"https:\\\/\\\/accelthinking.com\\\/zh_cn\\\/ccc-2023-s2-symmetric-mountains-solution-analysis\\\/\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/accelthinking.com\\\/#website\",\"url\":\"https:\\\/\\\/accelthinking.com\\\/\",\"name\":\"Accel Thinking\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/accelthinking.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-CN\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/accelthinking.com\\\/#\\\/schema\\\/person\\\/bb7b104098a9c6c91f4fe54c4ab4a348\",\"name\":\"ATI Builder\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-CN\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77af32770dc7e2c3451795691a8d8e3e2d0c9faa5af72043c703fa202bdcd81?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77af32770dc7e2c3451795691a8d8e3e2d0c9faa5af72043c703fa202bdcd81?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c77af32770dc7e2c3451795691a8d8e3e2d0c9faa5af72043c703fa202bdcd81?s=96&d=mm&r=g\",\"caption\":\"ATI Builder\"},\"url\":\"https:\\\/\\\/accelthinking.com\\\/zh_cn\\\/author\\\/ati-builder\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55","description":"\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002","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:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/","og_locale":"zh_CN","og_type":"article","og_title":"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55","og_description":"\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002","og_url":"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/","og_site_name":"Accel Thinking","article_published_time":"2026-10-03T12:00:00+00:00","article_modified_time":"2026-10-10T03:29:08+00:00","og_image":[{"url":"https:\/\/accelthinking.com\/wp-content\/plugins\/accel-analytics\/assets\/accel-thinking-og.png","type":"","width":"","height":""}],"author":"ATI Builder","twitter_card":"summary_large_image","twitter_title":"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55","twitter_description":"\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002","twitter_image":"https:\/\/accelthinking.com\/wp-content\/plugins\/accel-analytics\/assets\/accel-thinking-og.png","twitter_misc":{"Written by":"ATI Builder","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/#article","isPartOf":{"@id":"https:\/\/accelthinking.com\/ccc-2023-s2-symmetric-mountains-solution-analysis\/"},"author":{"name":"ATI Builder","@id":"https:\/\/accelthinking.com\/#\/schema\/person\/bb7b104098a9c6c91f4fe54c4ab4a348"},"headline":"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55","datePublished":"2026-10-03T12:00:00+00:00","dateModified":"2026-10-10T03:29:08+00:00","mainEntityOfPage":{"@id":"https:\/\/accelthinking.com\/ccc-2023-s2-symmetric-mountains-solution-analysis\/"},"wordCount":1856,"image":{"@id":"https:\/\/accelthinking.com\/ccc-2023-s2-symmetric-mountains-solution-analysis\/#primaryimage"},"thumbnailUrl":"https:\/\/accelthinking.com\/wp-content\/uploads\/2026\/06\/logo-dark-cropped-51.png","keywords":["C++","CCC 2023 S2","Center Expansion","Competitive Programming","Palindrome","Python","Symmetric Mountains","Two Pointers"],"articleSection":["CP Weekly Challenge"],"inLanguage":"zh-CN"},{"@type":"WebPage","@id":"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/","url":"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/","name":"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55","isPartOf":{"@id":"https:\/\/accelthinking.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/accelthinking.com\/ccc-2023-s2-symmetric-mountains-solution-analysis\/#primaryimage"},"image":{"@id":"https:\/\/accelthinking.com\/ccc-2023-s2-symmetric-mountains-solution-analysis\/#primaryimage"},"thumbnailUrl":"https:\/\/accelthinking.com\/wp-content\/uploads\/2026\/06\/logo-dark-cropped-51.png","datePublished":"2026-10-03T12:00:00+00:00","dateModified":"2026-10-10T03:29:08+00:00","author":{"@id":"https:\/\/accelthinking.com\/#\/schema\/person\/bb7b104098a9c6c91f4fe54c4ab4a348"},"description":"\u679a\u4e3e\u5947\u5076\u4e24\u7c7b\u4e2d\u5fc3\u5e76\u5411\u5916\u6269\u5c55\uff0c\u7528 O(N\u00b2) \u6c42\u51fa\u6bcf\u79cd\u88c1\u526a\u957f\u5ea6\u7684\u6700\u5c0f\u4e0d\u5bf9\u79f0\u503c\u3002","breadcrumb":{"@id":"https:\/\/accelthinking.com\/ccc-2023-s2-symmetric-mountains-solution-analysis\/#breadcrumb"},"inLanguage":"zh-CN","potentialAction":[{"@type":"ReadAction","target":["https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/"]}]},{"@type":"ImageObject","inLanguage":"zh-CN","@id":"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/#primaryimage","url":"https:\/\/accelthinking.com\/wp-content\/uploads\/2026\/06\/logo-dark-cropped-51.png","contentUrl":"https:\/\/accelthinking.com\/wp-content\/uploads\/2026\/06\/logo-dark-cropped-51.png"},{"@type":"BreadcrumbList","@id":"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/accelthinking.com\/"},{"@type":"ListItem","position":2,"name":"CCC 2023 S2 Symmetric Mountains \u9898\u89e3\uff1a\u56fa\u5b9a\u4e2d\u70b9\u5411\u5916\u6269\u5c55","item":"https:\/\/accelthinking.com\/zh_cn\/ccc-2023-s2-symmetric-mountains-solution-analysis\/"}]},{"@type":"WebSite","@id":"https:\/\/accelthinking.com\/#website","url":"https:\/\/accelthinking.com\/","name":"Accel Thinking","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/accelthinking.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-CN"},{"@type":"Person","@id":"https:\/\/accelthinking.com\/#\/schema\/person\/bb7b104098a9c6c91f4fe54c4ab4a348","name":"ATI Builder","image":{"@type":"ImageObject","inLanguage":"zh-CN","@id":"https:\/\/secure.gravatar.com\/avatar\/c77af32770dc7e2c3451795691a8d8e3e2d0c9faa5af72043c703fa202bdcd81?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c77af32770dc7e2c3451795691a8d8e3e2d0c9faa5af72043c703fa202bdcd81?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c77af32770dc7e2c3451795691a8d8e3e2d0c9faa5af72043c703fa202bdcd81?s=96&d=mm&r=g","caption":"ATI Builder"},"url":"https:\/\/accelthinking.com\/zh_cn\/author\/ati-builder\/"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/posts\/1916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/comments?post=1916"}],"version-history":[{"count":1,"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/posts\/1916\/revisions"}],"predecessor-version":[{"id":1917,"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/posts\/1916\/revisions\/1917"}],"wp:attachment":[{"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/media?parent=1916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/categories?post=1916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/accelthinking.com\/zh_cn\/wp-json\/wp\/v2\/tags?post=1916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}