Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "CITY"
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- using ld = long double;
- constexpr int N = 5e2 + 5;
- int m, n, k, l;
- int a[N][N], b[N][N], s[N * N];
- void Read()
- {
- cin >> m >> n >> k;
- for (int i = 1; i <= m; ++i)
- for (int j = 1; j <= n; ++j)
- cin >> a[i][j];
- }
- void Solve()
- {
- for (int i = 1; i <= m; ++i)
- for (int j = 1; j <= n; ++j)
- {
- // Tính lượng lương thực sản xuất ra từ các ô kề
- for (int t = -1; t <= 1; ++t)
- for (int h = -1; h <= 1; ++h)
- if (t != 0 || h != 0)
- b[i][j] += a[i + t][j + h];
- s[++l] = b[i][j]; // Duỗi ra mảng hai chiều
- }
- sort(s + 1, s + l + 1);
- for (int i = 1; i <= k; ++i)
- {
- int c;
- cin >> c;
- int j = lower_bound(s + 1, s + l + 1, c) - s;
- if (j <= l && s[j] == c)
- cout << 1 << " ";
- else
- cout << 0 << " ";
- }
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement