Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

using namespace std;
using pii=pair<int,int>;
using ll=long long;

struct LINE{
    int a,b,c;
};

ll f(vector<ll> &y, vector<ll> &x, int yidx, int xidx)
{
    return (y[yidx+1]-y[yidx])*(x[xidx+1]-x[xidx]);
}

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    vector<LINE> v1(n),v2(m);
    vector<ll> x={0},y={0};
    map<int,int> x2idx,y2idx;
    for(int i=0; i<n; i++){
        cin>>v1[i].a>>v[i].b>>v[i].c;
        y.push_back(v1[i].a);
        y.push_back(v1[i].b);
        x.push_back(v1[i].c);
    }
    for(int i=0; i<m; i++){
        cin>>v2[i].a>>v2[i].b>>v2[i].c;
        x.push_back(v2[i].a);
        x.push_back(v2[i].b);
        y.push_back(v2[i].c);
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    auto xend=unique(x.begin(),x.end());
    auto yend=unique(y.begin(),y.end());
    for(auto it=x.begin(); it!=xend; it++){
        x2idx.insert({*it,it-x.begin()});
    }
    for(auto it=y.begin(); it!=yend; it++){
        y2idx.insert({*it,it-y.begin()});
    }
    vector<vector<bool>> checkh(yend-y.begin(),vector<bool>(xend-x.begin()));
    vector<vector<bool>> checkv(yend-y.begin(),vector<bool>(xend-x.begin()));
    for(int i=0; i<n; i++){
        int yidx1=y2idx[v1[i].a];
        int yidx2=y2idx[v1[i].b];
        int xidx=x2idx[v1[i].c];
        for(int j=yidx1; j<yidx2; j++) checkv[j][xidx]=true;
    }
    for(int i=0; i<m; i++){
        int xidx1=x2idx[v2[i].a];
        int xidx2=x2idx[v2[i].b];
        int yidx=y2idx[v2[i].c];
        for(int j=xidx1; j<xidx2; j++) checkh[yidx][j]=true;
    }
    vector<vector<bool>> visited(yend-y.begin(),vector<bool>(xend-x.begin()));
    queue<pii> q;
    int sy=y2idx[0],sx=x2idx[0];
    q.push({sy,sx});
    visited[sy][sx]=true;
    ll answer=f(y,x,sy,sx);
    while(!q.empty()){
        pii now=q.front();
        q.pop();
        if(!checkv[now.ff][now.ss]){
            if(now.ss>0){
                if(!visited[now.ff][now.ss-1]){
                    q.push({now.ff,now.ss-1});
                    visited[now.ff][now.ss-1]=true;
                    answer+=f(y,x,now.ff,now.ss-1);
                }
            }
            else{
                answer=LLONG_MAX;
                break;
            }
        }
        if(!checkv[now.ff][now.ss+1]){
            if(now.ss<xend-x.begin()){
                if(!visited[now.ff][now.ss+1]){
                    q.push({now.ff,now.ss+1});
                    visited[now.ff][now.ss+1]=true;
                    answer+=f(y,x,now.ff,now.ss+1);
                }
            }
            else{
                answer=LLONG_MAX;
                break;
            }
        }
        if(!checkh[now.ff][now.ss]){
            if(now.ff>0){
                if(!visited[now.ff-1][now.ss]){
                    q.push({now.ff-1,now.ss});
                    visited[now.ff-1][now.ss]=true;
                    answer+=f(y,x,now.ff-1,now.ss);
                }
            }
            else{
                answer=LLONG_MAX;
                break;
            }
        }
        if(!checkh[now.ff+1][now.ss]){
            if(now.ff<yend-y.begin()){
                if(!visited[now.ff+1][now.ss]){
                    q.push({now.ff+1,now.ss});
                    visited[now.ff+1][now.ss]=true;
                    answer+=f(y,x,now.ff+1,now.ss);
                }
            }
            else{
                answer=LLONG_MAX;
                break;
            }
        }
    }
    if(answer==LLONG_MAX) cout<<"INF";
    else cout<<answer;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:23: error: 'v' was not declared in this scope
   45 |         cin>>v1[i].a>>v[i].b>>v[i].c;
      |                       ^