Language: C++

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

int _a[1000], _b[1000], _c[1000], _d[1000], _e[1000], _f[1000];
int az[1000], bz[1000], cz[1000], dz[1000], ez[1000], fz[1000];
vector<int> xs, ys;

int getidx_x(int x) {
    return lower_bound(xs.begin(), xs.end(), x) - xs.begin();
}

int getidx_y(int y) {
    return lower_bound(ys.begin(), ys.end(), y) - ys.begin();
}

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

bitset<7000> bo[7000];
bitset<7000> visit[7000];

int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;

    xs.emplace_back(-1.5e9);
    ys.emplace_back(-1.5e9);

    xs.emplace_back(0);
    ys.emplace_back(0);
    for (int i = 0; i < n; i++) {
        cin >> _a[i] >> _b[i] >> _c[i];
        xs.emplace_back(_a[i]), xs.emplace_back(_b[i]), ys.emplace_back(_c[i]);
    }
    for (int i = 0; i < m; i++) {
        cin >> _d[i] >> _e[i] >> _f[i];
        xs.emplace_back(_d[i]), ys.emplace_back(_e[i]), ys.emplace_back(_f[i]);
    }
    sort(xs.begin(), xs.end()), sort(ys.begin(), ys.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end()), ys.erase(unique(ys.begin(), ys.end()), ys.end());

    for (int i = 0; i < n; i++) {
        int az = getidx_x(_a[i]), bz = getidx_x(_b[i]), cz = getidx_y(_c[i]);
        for (int j = az * 2; j < bz * 2; j++) bo[j][cz * 2 - 1] = true;
    }
    for (int i = 0; i < m; i++) {
        int dz = getidx_x(_d[i]), ez = getidx_y(_e[i]), fz = getidx_y(_f[i]);
        for (int j = ez * 2; j < fz * 2; j++) bo[dz * 2 - 1][j] = true;
    }

    int s = getidx_x(0) * 2, e = getidx_y(0) * 2;

    bool inf = false;

    ll sum = 0;
    queue<pii> q;
    visit[s][e] = true;
    q.emplace(s, e);
    while (q.size()) {
        int x = q.front().first, y = q.front().second;
        if (x == 6999 || y == 6999 || !x || !y) {
            inf = true;
            break;
        }
        q.pop();
        if (!(x % 2) && !(y % 2)) {
            int i = x / 2, j = y / 2;
            sum += (xs[i] - xs[i - 1]) * (ys[j] - ys[j - 1]);
        }
        for (int d = 0; d < 4; d++) {
            int nx = x + dx[d];
            int ny = y + dy[d];
            if (7000 <= nx || nx < 0) continue;
            if (7000 <= ny || ny < 0) continue;
            if (visit[nx][ny]) continue;
            if (bo[nx][ny]) continue;
            visit[nx][ny] = true;
            q.emplace(nx, ny);
        }
    }

    if (!inf) {
        cout << sum;
    } else {
        cout << "INF";
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:5: error: reference to 'visit' is ambiguous
   70 |     visit[s][e] = true;
      |     ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:29:14: note:                 'std::bitset<7000> visit [7000]'
   29 | bitset<7000> visit[7000];
      |              ^~~~~
a.cc:88:17: error: reference to 'visit' is ambiguous
   88 |             if (visit[nx][ny]) continue;
      |                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:29:14: note:                 'std::bitset<7000> visit [7000]'
   29 | bitset<7000> visit[7000];
      |              ^~~~~
a.cc:90:13: error: reference to 'visit' is ambiguous
   90 |             visit[nx][ny] = true;
      |             ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:29:14: note:                 'std::bitset<7000> visit [7000]'
   29 | bitset<7000> visit[7000];
      |              ^~~~~