mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 15:56:26 +00:00
parent
19f97c44bc
commit
a0eb9a2927
75
S2OJ/1537/1537.cpp
Normal file
75
S2OJ/1537/1537.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
#include <queue>
|
||||||
|
#include <tuple>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 3005;
|
||||||
|
const int d[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
|
||||||
|
|
||||||
|
int n, m, k, q, id[N][N], dist[N][N], ans;
|
||||||
|
std::queue<std::pair<int, int>> queue;
|
||||||
|
bool g[N][N];
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
memset(dist, -0x3f, sizeof(dist));
|
||||||
|
|
||||||
|
cin >> n >> m >> k;
|
||||||
|
|
||||||
|
for (int i = 1, x, y; i <= k; i++) {
|
||||||
|
cin >> x >> y;
|
||||||
|
|
||||||
|
id[x][y] = i;
|
||||||
|
dist[x][y] = 0;
|
||||||
|
|
||||||
|
queue.emplace(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
cin >> q;
|
||||||
|
|
||||||
|
for (int i = 1, x, y; i <= q; i++) {
|
||||||
|
cin >> x >> y;
|
||||||
|
|
||||||
|
g[x][y] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!queue.empty()) {
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
std::tie(x, y) = queue.front();
|
||||||
|
queue.pop();
|
||||||
|
|
||||||
|
for (const auto &d : d) {
|
||||||
|
int xx = x + d[0],
|
||||||
|
yy = y + d[1];
|
||||||
|
|
||||||
|
if (xx < 1 || xx > n || yy < 1 || yy > m || g[xx][yy]) continue;
|
||||||
|
|
||||||
|
if (id[xx][yy] == 0) {
|
||||||
|
id[xx][yy] = id[x][y];
|
||||||
|
dist[xx][yy] = dist[x][y] + 1;
|
||||||
|
|
||||||
|
queue.emplace(xx, yy);
|
||||||
|
} else if (dist[x][y] + 1 == dist[xx][yy] && id[x][y] != id[xx][yy]) {
|
||||||
|
id[xx][yy] = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
for (int j = 1; j <= m; j++) {
|
||||||
|
if (id[i][j] == -1) ans++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << ans << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
S2OJ/1537/data/boundary1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/boundary9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/boundary9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1537/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1537/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user