CF183A.Headquarters

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Sensation, sensation in the two-dimensional kingdom! The police have caught a highly dangerous outlaw, member of the notorious "Pihters" gang. The law department states that the outlaw was driving from the gang's headquarters in his car when he crashed into an ice cream stall. The stall, the car, and the headquarters each occupies exactly one point on the two-dimensional kingdom.

The outlaw's car was equipped with a GPS transmitter. The transmitter showed that the car made exactly nn movements on its way from the headquarters to the stall. A movement can move the car from point (x,y)(x,y) to one of these four points: to point (x1,y)(x-1,y) which we will mark by letter "L", to point (x+1,y)(x+1,y) — "R", to point (x,y1)(x,y-1) — "D", to point (x,y+1)(x,y+1) — "U".

The GPS transmitter is very inaccurate and it doesn't preserve the exact sequence of the car's movements. Instead, it keeps records of the car's possible movements. Each record is a string of one of these types: "UL", "UR", "DL", "DR" or "ULDR". Each such string means that the car made a single movement corresponding to one of the characters of the string. For example, string "UL" means that the car moved either "U", or "L".

You've received the journal with the outlaw's possible movements from the headquarters to the stall. The journal records are given in a chronological order. Given that the ice-cream stall is located at point (0,0)(0,0) , your task is to print the number of different points that can contain the gang headquarters (that is, the number of different possible locations of the car's origin).

输入格式

The first line contains a single integer nn (1<=n<=2105)(1<=n<=2·10^{5}) — the number of the car's movements from the headquarters to the stall.

Each of the following nn lines describes the car's possible movements. It is guaranteed that each possible movement is one of the following strings: "UL", "UR", "DL", "DR" or "ULDR".

All movements are given in chronological order.

Please do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin and cout stream or the %I64d specifier.

输出格式

Print a single integer — the number of different possible locations of the gang's headquarters.

输入输出样例

  • 输入#1

    3
    UR
    UL
    ULDR
    

    输出#1

    9
    
  • 输入#2

    2
    DR
    DL
    

    输出#2

    4
    

说明/提示

The figure below shows the nine possible positions of the gang headquarters from the first sample:

For example, the following movements can get the car from point (1,0)(1,0) to point (0,0)(0,0) :

首页