Language: C++

#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int;
using P = pair<int, int>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const int MOD = 1000000007;
const int INF = 1<<30;
//const int INF = (int)1e18 + 1;

struct L{
  int a, b, c;
  L(int a = 0, int b = 0, int c = 0): a(a), b(b), c(c){}
};

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

int main(){
  int N, M; cin >> N >> M;
  //元々の座標
  //first: 元々の座標　second:圧縮後の座標
  map<int, int> mpX, mpY;
  mpX[0] = 0, mpY[0] = 0;

  vector<L> lh, lv;
  rep(i, N){
    int a, b, c; cin >> a >> b >> c;
    mpX[a] = 0;
    mpX[b] = 0;
    mpY[c] = 0;
    lh.emplace_back(a, b, c);
  }
  rep(i, M){
    int a, b, c; cin >> c >> a >> b;
    mpY[a] = 0;
    mpY[b] = 0;
    mpX[c] = 0;
    lv.emplace_back(a, b, c);
  }
  //圧縮する前の座標
  //xs[0]:圧縮後の座標0の元座標
  vector<int> xs, ys;
  for(auto& p: mpX){
    p.second = xs.size();
    xs.push_back(p.first);
  }
  for(auto& p: mpY){
    p.second = ys.size();
    ys.push_back(p.first);
  }

  //扱うグリッドのサイズ
  int h = xs.size() * 2;
  int w = ys.size() * 2;
  vector<vector<int>> d(h, vector<int>(w, 0));
  rep(i, N){
    int a = mpX[lh[i].a] * 2;
    int b = mpX[lh[i].b] * 2;
    int c = mpY[lh[i].c] * 2;
    for (int x = a; x <= b; ++x) d[x][c] = -1;
  }
  rep(i, N){
    int a = mpY[lv[i].a] * 2;
    int b = mpY[lv[i].b] * 2;
    int c = mpX[lv[i].c] * 2;
    for (int y = a; y <= b; ++y) d[c][y] = -1;
  }

  queue<P> q;
  int sx = mpX[0] * 2, sy = mpY[0] * 2;
  d[sx][sy] = 1;//たどり着けるところを1にする
  q.emplace(sx, sy);
  while (!q.empty()){
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    rep(v, 4){
      int nx = x + dx[v], ny = y + dy[v];
      if (nx < 0 || nx >= h) continue;
      if (ny < 0 || ny >= w) continue;
      if (d[nx][ny] != 0) continue;
      d[nx][ny] = 1;
      q.emplace(nx, ny);
    }
  }

  ll ans = 0;
  rep(x, h) rep(y, w){
    if (d[x][y] != 1) continue;
    if (x == 0 || x == h - 1 || y == 0 || y == w - 1){
      cout << "INF" << endl;
      return 0;
    }
    if (x % 2 == 0 || y % 2 == 0) continue;
    ll ex = xs[x / 2 + 1] - xs[x / 2];
    ll ey = ys[y / 2 + 1] - ys[y / 2];
    ans += ex * ey;
  }
  cout << ans << endl;
}


Compiler output:
a.cc:15:19: error: declaration does not declare anything [-fpermissive]
   15 | typedef long long int;
      |                   ^~~
a.cc: In function 'int main()':
a.cc:102:3: error: 'll' was not declared in this scope; did you mean 'lv'?
  102 |   ll ans = 0;
      |   ^~
      |   lv
a.cc:110:7: error: expected ';' before 'ex'
  110 |     ll ex = xs[x / 2 + 1] - xs[x / 2];
      |       ^~~
      |       ;
a.cc:111:7: error: expected ';' before 'ey'
  111 |     ll ey = ys[y / 2 + 1] - ys[y / 2];
      |       ^~~
      |       ;
a.cc:112:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
  112 |     ans += ex * ey;
      |     ^~~
      |     abs
a.cc:112:12: error: 'ex' was not declared in this scope; did you mean 'x'?
  112 |     ans += ex * ey;
      |            ^~
      |            x
a.cc:112:17: error: 'ey' was not declared in this scope; did you mean 'y'?
  112 |     ans += ex * ey;
      |                 ^~
      |                 y
a.cc:114:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
  114 |   cout << ans << endl;
      |           ^~~
      |           abs