本题整体上难度不大,只要仔细想想原理,模拟一下就好啦

b站视频:BV1qW65BvEjd

ac代码:

#include <bits/stdc++.h>
using namespace std;
#define sc second
#define fr first
#define int long long
#define itn long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define endl '\n'
#define enld '\n'
#define all(a) a.begin(), a.end()
#define ui unordered_map<int, int>
#define pi acos(-1)
const int N = 5e5 + 5;
// const int mod = 998244353;
// const int mod = 1e9 + 7;
int n, m, k, x, y, num, op, cnt = 0;
string s;
void _()
{   
    cin >> n;
    vi a(9);
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        if (x == 0)
        {
            int mx = max(a[y], a[y + 1]);
            a[y] = mx + 3;
            a[y + 1] = mx + 1;
        }
        if (x == 90)
        {
            if (a[y] >= a[y + 1] && a[y] >= a[y + 2])
            {
                a[y] += 2;
                a[y + 1] = a[y];
                a[y + 2] = a[y];
            }
            else
            {
                int mx = max({a[y], a[y + 1], a[y + 2]});
                a[y] = mx + 1;
                a[y + 2] = mx + 1;
                a[y + 1] = mx + 1;
            }
        }
        if (x == 180)
        {
            if (a[y + 1] + 2 >= a[y])
            {
                a[y + 1] += 3;
                a[y] = a[y + 1];
            }
            else
            {
                a[y]++;
                a[y + 1] = a[y];
            }
        }
        if (x == 270)
        {
            int mx = max({a[y], a[y + 1], a[y + 2]});
            a[y] = mx + 1;
            a[y + 2] = mx + 2;
            a[y + 1] = mx + 1;
        }
    }
    for (int i = 1; i <= 8; i++)
    {
        cout << a[i] << " ";
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int awa = 1;
    // cin >> awa;
    while (awa--)
    {
        _();
    }
    return 0;
}