#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int maxn = 310, maxc = 42;
int n, r, c;
int used[2 * maxc][2 * maxc];
int x[maxn], y[maxn];
void solve()
{
cin >> r >> c;
cin >> n;
for (int i = 1; i <= n; i ++)
cin >> x[i] >> y[i];
int ans = r + c - 2;
for (int h = 1; h <= r; h ++)
for (int w = 1; w <= c; w ++)
{
for (int i = 0; i < 2 * maxc; i ++)
for (int j = 0; j < 2 * maxc; j ++)
used[i][j] = 0;
for (int i = 1; i <= n; i ++)
{
for (int dx = x[i]; dx < x[i] + h; dx ++)
for (int dy = y[i]; dy < y[i] + w; dy ++)
{
used[dx][dy] = 1;
}
}
bool done = false;
for (int sx = 0; sx < 2 * maxc; sx ++)
for (int sy = 0; sy < 2 * maxc; sy ++)
{
bool tf = true;
for (int i = sx; i < sx + r; i ++)
for (int j = sy; j < sy + c; j ++)
{
if (used[i][j] == 0)
{
//if (h == 3 && w == 2 && sx == 1 && sy == 2)
// cout << sx << " : " << sy << " " << i << " " << j << endl;
tf = false;
break;
}
}
if (tf)
{
done = true;
break;
}
}
/*if (h == 3 && w == 2)
{
for (int i = 1; i <= 8; i ++, cout << endl)
for (int j = 1; j <= 8; j ++)
cout << used[i][j] << " ";
}*/
if (done)
{
ans = min(ans, h + w - 2);
}
}
cout << ans << endl;
}
int main()
{
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
34 ms |
348 KB |
Output is correct |
18 |
Correct |
227 ms |
440 KB |
Output is correct |
19 |
Correct |
1156 ms |
444 KB |
Output is correct |
20 |
Correct |
57 ms |
436 KB |
Output is correct |
21 |
Incorrect |
1061 ms |
440 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
34 ms |
348 KB |
Output is correct |
18 |
Correct |
227 ms |
440 KB |
Output is correct |
19 |
Correct |
1156 ms |
444 KB |
Output is correct |
20 |
Correct |
57 ms |
436 KB |
Output is correct |
21 |
Incorrect |
1061 ms |
440 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
600 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
34 ms |
348 KB |
Output is correct |
18 |
Correct |
227 ms |
440 KB |
Output is correct |
19 |
Correct |
1156 ms |
444 KB |
Output is correct |
20 |
Correct |
57 ms |
436 KB |
Output is correct |
21 |
Incorrect |
1061 ms |
440 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |