Submission #950388

# Submission time Handle Problem Language Result Execution time Memory
950388 2024-03-20T09:12:18 Z arbuzick Cell Automaton (JOI23_cell) C++17
16 / 100
8000 ms 2097152 KB
#include <bits/stdc++.h>

using namespace std;

void solve() {
    int n, q;
    cin >> n >> q;
    vector<pair<int, int>> xy(n);
    for (int i = 0; i < n; ++i) {
        cin >> xy[i].first >> xy[i].second;
    }
    vector<int> t(q);
    for (int i = 0; i < q; ++i) {
        cin >> t[i];
    }
    vector<int> ans(t[q - 1] + 1);
    ans[0] = xy.size();
    set<pair<int, int>> black, gray;
    for (int i = 0; i < n; ++i) {
        black.insert(xy[i]);
    }
    for (int i = 1; i <= t[q - 1]; ++i) {
        set<pair<int, int>> black_nw;
        for (auto [x, y] : black) {
            if (!black.count({x + 1, y}) && !gray.count({x + 1, y})) {
                black_nw.emplace(x + 1, y);
            }
            if (!black.count({x - 1, y}) && !gray.count({x - 1, y})) {
                black_nw.emplace(x - 1, y);
            }
            if (!black.count({x, y + 1}) && !gray.count({x, y + 1})) {
                black_nw.emplace(x, y + 1);
            }
            if (!black.count({x, y - 1}) && !gray.count({x, y - 1})) {
                black_nw.emplace(x, y - 1);
            }
        }
        gray = black;
        black = black_nw;
        ans[i] = black.size();
    }
    for (int i = 0; i < q; ++i) {
        cout << ans[t[i]] << '\n';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 13 ms 348 KB Output is correct
4 Correct 16 ms 348 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 14 ms 1372 KB Output is correct
9 Correct 15 ms 348 KB Output is correct
10 Correct 15 ms 344 KB Output is correct
11 Correct 15 ms 344 KB Output is correct
12 Correct 19 ms 816 KB Output is correct
13 Correct 18 ms 940 KB Output is correct
14 Correct 17 ms 860 KB Output is correct
15 Correct 17 ms 1112 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 3 ms 344 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 13 ms 348 KB Output is correct
4 Correct 16 ms 348 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 14 ms 1372 KB Output is correct
9 Correct 15 ms 348 KB Output is correct
10 Correct 15 ms 344 KB Output is correct
11 Correct 15 ms 344 KB Output is correct
12 Correct 19 ms 816 KB Output is correct
13 Correct 18 ms 940 KB Output is correct
14 Correct 17 ms 860 KB Output is correct
15 Correct 17 ms 1112 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 3 ms 344 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 979 ms 1364 KB Output is correct
30 Correct 1628 ms 1412 KB Output is correct
31 Correct 2548 ms 1584 KB Output is correct
32 Correct 4300 ms 42892 KB Output is correct
33 Correct 1636 ms 1928 KB Output is correct
34 Correct 1961 ms 1288 KB Output is correct
35 Correct 2000 ms 1412 KB Output is correct
36 Correct 230 ms 812 KB Output is correct
37 Correct 246 ms 1040 KB Output is correct
38 Correct 3949 ms 5808 KB Output is correct
39 Correct 4116 ms 17420 KB Output is correct
40 Correct 4173 ms 49036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 8042 ms 378844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 8042 ms 378844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3576 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3576 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 13 ms 348 KB Output is correct
4 Correct 16 ms 348 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 6 ms 348 KB Output is correct
7 Correct 7 ms 348 KB Output is correct
8 Correct 14 ms 1372 KB Output is correct
9 Correct 15 ms 348 KB Output is correct
10 Correct 15 ms 344 KB Output is correct
11 Correct 15 ms 344 KB Output is correct
12 Correct 19 ms 816 KB Output is correct
13 Correct 18 ms 940 KB Output is correct
14 Correct 17 ms 860 KB Output is correct
15 Correct 17 ms 1112 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 2 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 3 ms 348 KB Output is correct
24 Correct 3 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 3 ms 344 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 979 ms 1364 KB Output is correct
30 Correct 1628 ms 1412 KB Output is correct
31 Correct 2548 ms 1584 KB Output is correct
32 Correct 4300 ms 42892 KB Output is correct
33 Correct 1636 ms 1928 KB Output is correct
34 Correct 1961 ms 1288 KB Output is correct
35 Correct 2000 ms 1412 KB Output is correct
36 Correct 230 ms 812 KB Output is correct
37 Correct 246 ms 1040 KB Output is correct
38 Correct 3949 ms 5808 KB Output is correct
39 Correct 4116 ms 17420 KB Output is correct
40 Correct 4173 ms 49036 KB Output is correct
41 Execution timed out 8042 ms 378844 KB Time limit exceeded
42 Halted 0 ms 0 KB -