#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
const int nx=305;
int sr, sc, n, a[nx], b[nx], qs[nx][nx], res=INT_MAX;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>sr>>sc>>n;
for (int i=1; i<=n; i++) cin>>a[i]>>b[i];
for (int up=0; up<sr; up++)
{
for (int dn=0; dn<sr; dn++)
{
for (int l=0; l<sc; l++)
{
for (int r=0; r<sc; r++)
{
if (up+dn+l+r>sr+sc||up+dn+l+r>=res) continue;
for (int i=1; i<=sr; i++) for (int j=1; j<=sc ;j++) qs[i][j]=0;
for (int i=1; i<=n; i++) for (int j=max(1, a[i]-up); j<=min(sr, a[i]+dn); j++) qs[j][max(1, b[i]-l)]++, qs[j][min(sc, b[i]+r)+1]--;
for (int i=1; i<=sr; i++) for (int j=1; j<=sc; j++) qs[i][j]+=qs[i][j-1];
bool f=0;
for (int i=1; i<=sr; i++) for (int j=1; j<=sc; j++) if (qs[i][j]==0) f=1;
if (!f) res=min(res, up+dn+l+r);
}
}
}
}
cout<<res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
205 ms |
348 KB |
Output is correct |
20 |
Correct |
4 ms |
348 KB |
Output is correct |
21 |
Correct |
464 ms |
492 KB |
Output is correct |
22 |
Correct |
44 ms |
344 KB |
Output is correct |
23 |
Correct |
471 ms |
348 KB |
Output is correct |
24 |
Correct |
16 ms |
348 KB |
Output is correct |
25 |
Correct |
35 ms |
348 KB |
Output is correct |
26 |
Correct |
70 ms |
348 KB |
Output is correct |
27 |
Correct |
24 ms |
344 KB |
Output is correct |
28 |
Correct |
18 ms |
348 KB |
Output is correct |
29 |
Correct |
9 ms |
348 KB |
Output is correct |
30 |
Correct |
13 ms |
348 KB |
Output is correct |
31 |
Correct |
9 ms |
344 KB |
Output is correct |
32 |
Correct |
12 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
205 ms |
348 KB |
Output is correct |
20 |
Correct |
4 ms |
348 KB |
Output is correct |
21 |
Correct |
464 ms |
492 KB |
Output is correct |
22 |
Correct |
44 ms |
344 KB |
Output is correct |
23 |
Correct |
471 ms |
348 KB |
Output is correct |
24 |
Correct |
16 ms |
348 KB |
Output is correct |
25 |
Correct |
35 ms |
348 KB |
Output is correct |
26 |
Correct |
70 ms |
348 KB |
Output is correct |
27 |
Correct |
24 ms |
344 KB |
Output is correct |
28 |
Correct |
18 ms |
348 KB |
Output is correct |
29 |
Correct |
9 ms |
348 KB |
Output is correct |
30 |
Correct |
13 ms |
348 KB |
Output is correct |
31 |
Correct |
9 ms |
344 KB |
Output is correct |
32 |
Correct |
12 ms |
348 KB |
Output is correct |
33 |
Runtime error |
2 ms |
1236 KB |
Execution killed with signal 11 |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1116 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1116 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
360 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
205 ms |
348 KB |
Output is correct |
20 |
Correct |
4 ms |
348 KB |
Output is correct |
21 |
Correct |
464 ms |
492 KB |
Output is correct |
22 |
Correct |
44 ms |
344 KB |
Output is correct |
23 |
Correct |
471 ms |
348 KB |
Output is correct |
24 |
Correct |
16 ms |
348 KB |
Output is correct |
25 |
Correct |
35 ms |
348 KB |
Output is correct |
26 |
Correct |
70 ms |
348 KB |
Output is correct |
27 |
Correct |
24 ms |
344 KB |
Output is correct |
28 |
Correct |
18 ms |
348 KB |
Output is correct |
29 |
Correct |
9 ms |
348 KB |
Output is correct |
30 |
Correct |
13 ms |
348 KB |
Output is correct |
31 |
Correct |
9 ms |
344 KB |
Output is correct |
32 |
Correct |
12 ms |
348 KB |
Output is correct |
33 |
Runtime error |
2 ms |
1236 KB |
Execution killed with signal 11 |
34 |
Halted |
0 ms |
0 KB |
- |