Submission #965218

#TimeUsernameProblemLanguageResultExecution timeMemory
965218Gromp15Cell Automaton (JOI23_cell)C++17
16 / 100
734 ms140872 KiB
#include <bits/stdc++.h> #define ll long long #define ar array #define db double #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define rint(l, r) uniform_int_distribution<int>(l, r)(rng) template<typename T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; } template<typename T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; } const int N = 2100; void test_case() { int n, Q; cin >> n >> Q; queue<ar<int, 2>> q; vector<vector<int>> dist(2*N, vector<int>(2*N, 1e9)); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; x += N, y += N; dist[x][y] = 0; q.push({x, y}); } const int dx[]{0, 1, 0, -1}, dy[]{1, 0, -1, 0}; while (q.size()) { auto [x, y] = q.front(); q.pop(); for (int d = 0; d < 4; d++) { int nx = x + dx[d], ny = y + dy[d]; if (nx >= 0 && ny >= 0 && nx < 2*N && ny < 2*N && ckmin(dist[nx][ny], dist[x][y] + 1)) { q.push({nx, ny}); } } } const int T = 1000; vector<int> ans(T + 1); for (int i = 0; i < 2*N; i++) { for (int j = 0; j < 2*N; j++) { if (dist[i][j] <= T) { ans[dist[i][j]]++; } } } while (Q--) { int t; cin >> t; cout << ans[t] << '\n'; } } int main() { cin.tie(0)->sync_with_stdio(0); int t = 1; // cin >> t; while (t--) test_case(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...