-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa10667.cpp
More file actions
65 lines (63 loc) · 1.36 KB
/
UVa10667.cpp
File metadata and controls
65 lines (63 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// WIP, doesn't pass sample yet
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
// shortcuts for "common" data types in contests
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
vector<vi> memo;
int main()
{
int p; scanf("%d\n", &p);
while (p--)
{
int s; scanf("%d\n", &s);
int n; scanf("%d\n", &n);
vector<vector<bool>> grid(s, vector<bool>(s, false));
memo.assign(s, vi(s, -1));
for (int i = 0; i < n; i++)
{
int r1, c1, r2, c2; scanf("%d %d %d %d\n", &r1, &c1, &r2, &c2);
r1--; c1--; r2--; c2--;
for (int j = r1; j <= r2; j++)
{
for (int k = c1; k <= c2; k++)
{
grid.at(j).at(k) = true;
}
}
}
int maxSize = 0;
for (int i = 0; i < s; i++)
{
for (int j = 0; j < s; j++)
{
if ((i == 0 && j == 0) || grid.at(i).at(j))
memo.at(i).at(j) = 0;
else if (i == 0)
{
memo.at(i).at(j) = memo.at(i).at(j - 1) + 1;
}
else if (j == 0)
{
memo.at(i).at(j) = memo.at(i - 1).at(j) + 1;
}
else
{
memo.at(i).at(j) = memo.at(i - 1).at(j) + memo.at(i).at(j - 1) - memo.at(i - 1).at(j - 1) + 1;
}
maxSize = max(maxSize, memo.at(i).at(j));
printf("%4d ", memo.at(i).at(j));
}
printf("\n");
}
printf("%d\n", maxSize);
}
return 0;
}