You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.5 KiB
C++
64 lines
1.5 KiB
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
const int N = 2e6 + 600;
|
|
using ll = long long;
|
|
struct Point
|
|
{
|
|
ll x, y;
|
|
Point operator-(const Point &b) const { return Point{x - b.x, y - b.y}; }
|
|
ll operator^(const Point &b) const { return x * b.y - y * b.x; }
|
|
ll operator*(const Point &b) const { return x * b.x + y * b.y; }
|
|
} ps[N];
|
|
int pcnt, d;
|
|
ll dx[] = {0, 1, 0, -1};
|
|
ll dy[] = {1, 0, -1, 0};
|
|
void opA()
|
|
{
|
|
int x, y;
|
|
scanf("%d%d", &x, &y);
|
|
ps[pcnt++] = {ps[pcnt - 1].x + dx[d] * x, ps[pcnt - 1].y + dy[d] * x};
|
|
d = (d + 1) & 3;
|
|
ps[pcnt++] = {ps[pcnt - 1].x + dx[d] * y, ps[pcnt - 1].y + dy[d] * y};
|
|
d = (d + 1) & 3;
|
|
}
|
|
void opB()
|
|
{
|
|
int x, y;
|
|
scanf("%d%d", &x, &y);
|
|
ps[pcnt++] = {ps[pcnt - 1].x + dx[d] * x, ps[pcnt - 1].y + dy[d] * x};
|
|
d = (d + 3) & 3;
|
|
ps[pcnt++] = {ps[pcnt - 1].x + dx[d] * y, ps[pcnt - 1].y + dy[d] * y};
|
|
d = (d + 3) & 3;
|
|
}
|
|
int main()
|
|
{
|
|
ps[pcnt++] = {0, 0};
|
|
int n, x, y, z, w;
|
|
scanf("%d", &n);
|
|
char op[3];
|
|
while (n--)
|
|
{
|
|
scanf("%s", op);
|
|
switch (*op)
|
|
{
|
|
case 'A':
|
|
opA();
|
|
break;
|
|
case 'B':
|
|
opB();
|
|
break;
|
|
case 'C':
|
|
opA();
|
|
opA();
|
|
break;
|
|
}
|
|
}
|
|
ll sum = 0;
|
|
for (int i = 1; i < pcnt; i++)
|
|
sum += ps[i - 1] ^ ps[i];
|
|
printf("%lld\n", abs(sum) >> 1);
|
|
return 0;
|
|
}
|