luogu#P4967. 黑暗打击

黑暗打击

Background

Note: This problem is not the same as CQOI’s “Mole”. Please read the problem carefully. This problem only borrows the background.

In the vast universe...

Problem Description

There is a group of creatures called ccj. In the last galaxy, they discovered a group of low-level creatures, so they want to launch a “Dark Forest strike”. These low-level creatures are Hilbert\mathsf{Hilbert} moles. They live on the Hilbert\mathsf{Hilbert} planet and stay inside the soil of the Hilbert\mathsf{Hilbert} curve.

These creatures decide to use the dumbest method—flooding—to drown them. Now the “advanced” creatures want to know: for an nn-order Hilbert\mathsf{Hilbert} curve, if water is poured from top to bottom, how many unit areas can be flooded?

These are the Hilbert\mathsf{Hilbert} curves of order 141 \sim 4:

h1h_1, as shown in the leftmost figure, is a square missing an opening at the top, and the side length of this square is 11. Starting from h2h_2, construct the curve hih_i in the following way: copy hi1h_{i-1} four times and place them in a 2×22 \times 2 layout. Rotate the top-left copy 9090^\circ counterclockwise, rotate the top-right copy 9090^\circ clockwise, then use three unit segments to connect the four sub-curves in the order top-left → bottom-left → bottom-right → top-right. As shown in the figures, they are h2h_2, h3h_3, and h4h_4 respectively. The bold segments are the extra segments used for connection.

Flooding rules:

(Obviously, this is the flooded area of h3h_3.) Green areas are places that cannot be reached by water, red areas are places that can be reached by water, and gray areas are walls. So the answer is 2626, which is Sample 1.

A cell has water if and only if at least one of the cells above it, to its left, or to its right has water. All empty cells in the topmost row have water.

Note: this problem requires taking modulo 92233720368547757839223372036854775783.

Input Format

An integer nn, meaning this cave is an nn-order Hilbert\mathsf{Hilbert} curve.

Output Format

An integer ansans, meaning there are ansans unit areas flooded.

3

26

4

100

12
2137408

Hint

Sample explanation:

Count it yourself...

Constraints: n1010000n \le 10^{10000}.

For detailed constraints, see the “standard solution”.

All testdata are manually constructed. Please pay attention to constants.

Translated by ChatGPT 5