#P10096. [ROIR 2023] 扫地机器人 (Day 1)
[ROIR 2023] 扫地机器人 (Day 1)
Background
Translated from ROIR 2023 D1T3。
A cleaning robot is cleaning a 2D coordinate plane. The cleaning robot is a square of side length , with its sides parallel to the coordinate axes. Initially, the bottom-left corner of the robot is at , and the top-right corner is at .
Problem Description
You are given a sequence of move operations. The -th move operation consists of a direction (N means up, increasing the coordinate; E means right, increasing the coordinate; W means left, decreasing the coordinate; S means down, decreasing the coordinate) and a distance (the distance the robot moves). Based on the given robot moves, compute the total cleaned area (a point is considered cleaned if it has been covered by the robot at least once).
Input Format
The first line contains two integers: the robot size and the number of operations .
In the next lines, each line contains one move operation and the corresponding distance . The move operation is given by a letter (N for up, E for right, W for left, S for down), and the distance is an integer.
Output Format
Output the total area cleaned by the robot.
1 5
E 2
N 2
W 4
S 4
E 4
17
3 4
W 2
N 1
W 1
N 2
27
Hint
Sample explanation: The figure below shows the robot movements in the two samples.

Constraints
This problem uses bundled testdata.
| Subtask ID | Points | |||
|---|---|---|---|---|
| ^ | ||||
| ^ | ^ | |||
| ^ | ||||
For of the testdata, , , .
Translated by ChatGPT 5