Here is a question: codeforces 183a Zoo
I was surprised when I did not think about how to do this. Although I noticed that the two examples made up a square, I still didn't think about it.
You can draw one by yourself:
1. At the beginning, a vertex is [0, 0] in a row and a column.
2.1 go to the top left [-] [0, 1] and tilt two points in one row and two columns at 45 degrees.
2.2 go to the bottom right [] [0,-1] and tilt a row with 45 degrees, two columns and two vertices
2.3 go to the lower left [-] [0,-1] Two rows, one column, and two vertices
2.4 go to the upper right [] [], two rows, one column, and two vertices
You can also guess what the four directions are like. The rows and columns are added.
Therefore, after a few steps, a skewed rectangle is formed, and the number of points is the area of the rectangle.
Paste someone else's code
#include <string.h>#include <algorithm>using namespace std;typedef __int64 LL;#define inf 10000000#define N 20010int main (){LL n, num[5];char str[5];while (scanf ("%I64d", &n) != EOF) {memset(num, 0,sizeof(num));for (LL i = 0; i < n; ++i) {scanf ("%s", str);if(strcmp (str, "UR")==0) num[1] ++;if(strcmp (str, "UL")==0) num[2] ++;if(strcmp (str, "DR")==0) num[4] ++;if(strcmp (str, "DL")==0) num[3] ++;if(strcmp (str, "ULDR")==0) num[0] ++;}LL len1, len2, ans;len1 = 1 + num[1] + num[3] +num[0];len2 = 1 + num[2] + num[4] +num[0];ans = len1 *len2;printf("%I64d\n", ans);}return 0;}