Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cstdlib>
- #include <algorithm>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <climits>
- #include <string>
- #include <set>
- #include <cmath>
- #include <map>
- #include <unordered_map>
- #include <numeric>
- #include <random>
- #include <memory>
- #include <chrono>
- #include <functional>
- #include <unordered_set>
- #include <cstring>
- #include <cassert>
- #include <bitset>
- #ifdef LOCAL
- #include "debug.h"
- #else
- #define debug(x...)
- #endif
- //#define int ll
- //#pragma GCC optimize("Ofast")
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef pair <int, int> pii;
- typedef pair <ll, ll> pll;
- #define sz(x) int((x).size())
- #ifndef LOCAL
- mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
- #else
- mt19937 rng(228);
- #endif
- const int N = 1e3 + 7;
- const int inf = INT_MAX / 2;
- const ll INF = LLONG_MAX / 3;
- const int MOD = 998244353;
- const ld eps = 1e-6;
- const string cars[] = {"π", "π", "π"};
- struct Hasher {
- size_t operator()(const pii& x) const {
- return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
- }
- };
- unordered_map < pii, bool, Hasher > used;
- const vector < pii > mv = { { 0, -1 }, { 0, 1 }, { 1, 0 }, { -1, 0 } };
- void bfs(int xs, int ys, int t) {
- used[{ xs, ys }] = true;
- queue < tuple < int, int, int > > q;
- q.push({ xs, ys, t });
- while (!q.empty()) {
- auto [x, y, t] = q.front();
- q.pop();
- if (t > 0) {
- for (auto [mx, my] : mv) {
- if (!used[{ x + mx, y + my }]) {
- used[{ x + mx, y + my }] = true;
- q.push({ x + mx, y + my, t - 1 });
- }
- }
- }
- }
- }
- signed main() {
- #ifdef LOCAL
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- cout << fixed << setprecision(9);
- ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
- int k, c, t;
- cin >> k >> c >> t;
- if (k == 1 && c == 0) {
- cout << 1LL * 2 * t * (t + 1) + 1 << endl;
- }
- else {
- vector < pii > a(k);
- for (int i = 0; i < k; i++) {
- cin >> a[i].first >> a[i].second;
- }
- for (int i = 0; i < c; i++) {
- int x, y;
- cin >> x >> y;
- used[{ x, y }] = true;
- }
- for (auto[x, y] : a) {
- bfs(x, y, t);
- }
- int ans = 0;
- for (auto[x, y] : used) {
- ans += y;
- }
- cout << ans - c << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment