Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
??
using namespace std;
??
#define y1 hogwhoasjfd
??
#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
??
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;
??
template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
??
constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;
??
int w, h;
int n;
int x1[1005], x2[1005];
int y1[1005], y2[1005];
??
bool fld[1005*6+2][1005*6+2];
??
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
??
int compress(int *x1, int *x2, int w)
{
????????vi xs;
??
????????rep(i, n) {
????????????????for (int d = -1; d <= 1; ++d) {
????????????????????????int tx1 = x1[i] + d, tx2 = x2[i] + d;
??
????????????????????????if (0 <= tx1 && tx1 <= w) xs.PB(tx1);
????????????????????????if (0 <= tx2 && tx2 <= w) xs.PB(tx2);
????????????????}
????????}
??
????????sort(all(xs));
??//??????xs.erase(unique(all(xs)), end(xs));
??
????????rep(i, n) {
????????????????x1[i] = lower_bound(all(xs), x1[i]) - begin(xs);
????????????????x2[i] = lower_bound(all(xs), x2[i]) - begin(xs);
????????}
??
????????return xs.size();
}
??
int main()
{
????????while (cin >> w >> h, w) {
????????????????cin >> n;
??
????????????????memset(fld, 0, sizeof fld);
??
????????????????rep(i, n) {
????????????????????????cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
????????????????}
??
????????????????w = compress(x1, x2, w);
????????????????h = compress(y1, y2, h);
??
????????????????rep(i, n) {
????????????????????????for (int y = y1[i]; y <= y2[i]-1; ++y) {
????????????????????????????????for (int x = x1[i]; x <= x2[i]-1; ++x) {
????????????????????????????????????????fld[y][x] = true;
????????????????????????????????}
????????????????????????}
????????????????}
??
????????????????int ans = 0;
??
????????????????rep(y, h-1) rep(x, w-1) {
????????????????????????if (fld[y][x]) continue;
??
????????????????????????ans++;
??
????????????????????????queue<pii> q;
????????????????????????q.push(pii(y, x));
??
????????????????????????while (q.size()) {
????????????????????????????????pii p = q.front(); q.pop();
????????????????????????????????rep(i, 4) {
????????????????????????????????????????int ny = p.fst + dy[i], nx = p.scd + dx[i];
??
????????????????????????????????????????if (ny < 0 || ny >= h-1 || nx < 0 || nx >= w-1 || fld[ny][nx]) continue;
??
????????????????????????????????????????fld[ny][nx] = true;
????????????????????????????????????????q.push(pii(ny, nx));
????????????????????????????????}
????????????????????????}
????????????????}
??
????????????????cout << ans << endl;
????????}
}

Compiler output:
a.cc:75:1: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]
   75 | ??//??????xs.erase(unique(all(xs)), end(xs));
a.cc:18:1: error: expected unqualified-id before '?' token
   18 | ??
      | ^
a.cc:20:1: error: expected unqualified-id before '?' token
   20 | ??
      | ^
a.cc:35:10: error: 'vector' does not name a type
   35 | using vi=vector<int>;
      |          ^~~~~~
a.cc:36:11: error: 'vector' does not name a type
   36 | using vvi=vector<vi>;
      |           ^~~~~~
a.cc:37:11: error: 'pair' does not name a type
   37 | using pii=pair<int, int>;
      |           ^~~~
a.cc:38:12: error: 'vector' does not name a type
   38 | using vpii=vector<pii>;
      |            ^~~~~~
a.cc:39:1: error: expected unqualified-id before '?' token
   39 | ??
      | ^
a.cc:41:18: error: 'ostream' does not name a type
   41 | template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
      |                  ^~~~~~~
a.cc:46:1: error: expected unqualified-id before '?' token
   46 | ??
      | ^
a.cc:48:11: error: 'll' does not name a type; did you mean 'ld'?
   48 | constexpr ll linf = 3e18;
      |           ^~
      |           ld
a.cc:50:1: error: expected unqualified-id before '?' token
   50 | ??
      | ^
a.cc:55:1: error: expected unqualified-id before '?' token
   55 | ??
      | ^
a.cc:57:1: error: expected unqualified-id before '?' token
   57 | ??
      | ^
a.cc:60:1: error: expected unqualified-id before '?' token
   60 | ??
      | ^
a.cc:84:1: error: expected unqualified-id before '?' token
   84 | ??
      | ^