We are in an infinite table (on all sides), which is the color of all the houses except…
- User
We are in an infinite table (on all sides), which is the color of all the houses except the house ( 0 , 0 ) (0,0) is white and the color of the house ( 0 , 0 ) (0,0) is red. First, we are at home ( 0 , 0 ) We are located at (0,0) and at each stage we can go to one of the four directions: up, right, left, down, and to every house we go to, the color of that house will be red (we can see a house more than once, but its color stays red).
The maximum area between the maximally connected subsets of white houses whose all houses are enclosed between red houses is equal to the security of our moves. Now Kevin has given you a way to move through the table and wants you to get the security of the moves.
A subset of white houses of the table is called connected if there is at least one path between any two houses. A path from home a a to home b b is a sequence of houses that is the first member of the sequence of houses a a and the last member of the house sequence b b, all the houses in the sequence are members of the subset and both consecutive houses in the sequence are diagonally adjacent to each other. A maximal subset of the white houses of the matching table is the subset whose houses are enclosed between the red houses. Pay attention to the examples to better understand the question.
input In the single input line of the string s s is given, each house of which:
If it is R, it means moving to the right. If it is L, it means moving to the left. If it is D, it means downward movement. If it is U, it means upward movement. 1 ≤ ∣ s ∣ ≤ 400
000 1≤∣s∣≤400 000
meaning of ∣ s ∣ ∣s∣ string length s s is
output Output movements in the only security output line.
Example Sample entry 1 RDRURDRDLU Plain text Sample output 1 0 Plain text Explanation: The moves are as follows: (. is the white houses and R is the red houses and S is the starting point)
.......... .......... .......... .......... ....SRRR.. .....RRRR. .......RR. .......... .......... .......... Plain text Sample input 2 RRRRDDLLUDLUUUURRRRD Plain text Sample output 2 2 Plain text Explanation: The moves are as follows: (. is the white houses and R is the red houses and S is the starting point)
.......... ..RRRR.... ..R..R.... ..SRRRR... ..R.R.R... ..RRRRRR... .......... .......... .......... .......... Plain text Sample entry 3 RDDLLU Plain text Sample output 3 1 Plain text Explanation: The moves are as follows: (. is the white houses and R is the red houses and S is the starting point)
........ ........ ...SR... ..R.R... ..RRR... ........ ........ Plain text Sample entry 4 RRRRUUUULLLLLDDDDDDLLLUUURRR Plain text Sample output 4 9 Plain text Explanation: The moves are as follows: (. is the white houses and R is the red houses and S is the starting point)
............ ............ .....RRRRRR.. .....R...R.. .....R...R.. .....R...R.. ..RRRRRRRR.. ..R..R...... ..R..R...... ..RRRR...... ............ ............ Plain text This figure has only two maximally connected subsets, one of which is 9 and the other is 4. So its security is equal to 9. write in c++
- Assistant