#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
using namespace std;
#define endl "\n"
#define MAX 100+1
int m, n, k;
bool map[MAX][MAX];
bool visited[MAX][MAX];
int cnt;
int ans;
int dy[] = { 0,0,1,-1 };
int dx[] = { 1,-1,0,0 };
vector<int> area;
void dfs(int y, int x) {
visited[y][x] = true;
cnt++;
for (int i = 0; i < 4; i++)
{
int nx = x + dx[i];
int ny = y + dy[i];
if (nx<0 || nx>=n || ny<0 || ny>=m)
{
continue;
}
if (!map[ny][nx] && !visited[ny][nx])
{
dfs(ny, nx);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
//ifstream cin; cin.open("input.txt");
cin >> m >> n >> k;
while (k--)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
for (int i = y1; i <= y2-1; i++)
{
for (int j = x1; j <= x2-1; j++)
{
map[i][j] = true;
}
}
}
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
if (!map[i][j] && !visited[i][j])
{
ans++;
cnt = 0;
dfs(i, j);
area.push_back(cnt);
}
}
}
cout << ans << endl;
sort(area.begin(), area.end());
for (int i = 0; i < area.size(); i++)
{
cout << area[i] << ' ';
}
}
https://coding-factory.tistory.com/595 벡터 정렬 방법, sort함수