HBC21525方块 III,线段树,数据结构Origami题解

回忆凄美了谁 算法基础篇 47 0
想要成为编程高手?那就来试试全网最全C++题库,让您在练习中快速成长。
Chiaki has a very big sheet of paper. This sheet has a form of rectangle with dimensions 1 x n and numbers from 1 to n was written on each small 1 x 1 grid. Chiaki would like to fold the paper using t

Chiaki has a very big sheet of paper. This sheet has a form of rectangle with dimensions 1 x n and numbers from 1 to n was written on each small 1 x 1 grid. Chiaki would like to fold the paper using the following operations: Fold the sheet of paper at position pi to the right. After this query the leftmost part of the paper with dimensions 1 x pi must be above the rightmost part of the paper with dimensions 1×([current width of sheet]−pi1 times ([textit{current width of sheet}] - p_i1×([current width of sheet]−pi​). Fold the sheet of paper at position pi to the left. After this query the rightmost part of the paper with dimensions 1×([current width of sheet]−pi1 times ([textit{current width of sheet}] - p_i1×([current width of sheet]−pi​) must be above the leftmost part of the paper with dimensions 1 x pi. After performing the above operations several times, the sheet of paper has dimensions 1 x 1. If we write down the number on each grid from top to bottom, we will have a permutation of n. Now given a permutation of n, Chiaki would like to know whether it is possible to obtain the permutation using the above operations.

HBC21525方块 III,线段树,数据结构Origami题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC21525方块 III 线段树 数据结构Origami题解