CF183A.Headquarters
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
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 n movements on its way from the headquarters to the stall. A movement can move the car from point (x, y) to one of these four points: to point (x - 1, y) which we will mark by letter "L", to point (x + 1, y) — "R", to point (x, y - 1) — "D", to point (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), 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).
感官,二维王国中的感官!警方抓获了一名极度危险的逃犯,他是臭名昭著的“Pihters”帮派成员。执法部门称,该逃犯驾驶汽车从帮派总部出发,途中撞上了一家冰淇淋摊。该冰淇淋摊、汽车及帮派总部各自恰好占据二维王国中的一个点。
逃犯的汽车装备了GPS发射器。该发射器显示,汽车从总部驶向冰淇淋摊的过程中,恰好进行了 $ n $ 次移动。每次移动可将汽车从点 $ (x, y) $ 移动至以下四个点之一:点 $ (x - 1, y) $(记为字母 "L"),点 $ (x + 1, y) $(记为 "R"),点 $ (x, y - 1) $(记为 "D"),或点 $ (x, y + 1) $(记为 "U")。
该GPS发射器精度极低,无法保存汽车移动的确切顺序。它仅记录汽车可能的移动方式。每条记录是一个如下类型之一的字符串:"UL"、"UR"、"DL"、"DR" 或 "ULDR"。每个这样的字符串表示:汽车执行了一次移动,其方向是该字符串中某个字符所代表的方向。例如,字符串 "UL" 表示汽车移动的方向要么是 "U",要么是 "L"。
你已收到该逃犯从总部驶向冰淇淋摊过程中可能移动方式的日志。日志记录按时间先后顺序给出。已知冰淇淋摊位于点 $ (0, 0) $,你的任务是输出可能的帮派总部位置(即汽车出发点)的不同点的数量。
输入格式
The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of the car's movements from the headquarters to the stall.
Each of the following n 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.
第一行包含一个整数 n(1≤n≤2⋅105)——表示汽车从总部驶向摊位过程中移动的次数。
接下来的 n 行,每行描述一次汽车可能的移动。保证每次移动均为以下字符串之一:“UL”、“UR”、“DL”、“DR” 或 “ULDR”。
所有移动均按时间顺序给出。
在 C++ 中读写 64 位整数时,请勿使用 %lld 说明符。推荐使用 cin 和 cout 流,或 %I64d 说明符。
输出格式
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) to point (0, 0):

下图展示了第一个样例中帮派总部的九种可能位置:

例如,以下移动路径可使汽车从点 (1,0) 到达点 (0,0):

输入解题思路,AI测评打分。不知道怎么写?