Submission #1045811

# Submission time Handle Problem Language Result Execution time Memory
1045811 2024-08-06T07:53:10 Z 정민찬(#11016) Cell Automaton (JOI23_cell) C++17
16 / 100
979 ms 398292 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

ll dist[5010][5010];
ll vis[5010][5010];
ll dx[] = {1, -1, 0, 0};
ll dy[] = {0, 0, 1, -1};

int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL);
    ll N, Q;
    cin >> N >> Q;
    queue<pair<ll,ll>> q;
    for (ll i=0; i<N; i++) {
        ll x, y;
        cin >> x >> y;
        x += 2500; y += 2500;
        dist[x][y] = 0;
        vis[x][y] = 1;
        q.push({x, y});
    }
    vector<ll> ans(1010, 0);
    while (!q.empty()) {
        ll x = q.front().first;
        ll y = q.front().second;
        q.pop();
        if (dist[x][y] <= 1000) ans[dist[x][y]] ++;
        for (ll i=0; i<4; i++) {
            ll nx = x + dx[i];
            ll ny = y + dy[i];
            if (nx < 0 || nx >= 5000 || ny < 0 || ny >= 5000) continue;
            if (vis[nx][ny]) continue;
            dist[nx][ny] = dist[x][y] + 1;
            vis[nx][ny] = 1;
            q.push({nx, ny});
        }
    }
    while (Q --) {
        ll t;
        cin >> t;
        cout << ans[t] << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 624 ms 392652 KB Output is correct
2 Correct 648 ms 392784 KB Output is correct
3 Correct 636 ms 392788 KB Output is correct
4 Correct 636 ms 392692 KB Output is correct
5 Correct 644 ms 392596 KB Output is correct
6 Correct 646 ms 392764 KB Output is correct
7 Correct 676 ms 392564 KB Output is correct
8 Correct 670 ms 392788 KB Output is correct
9 Correct 721 ms 392632 KB Output is correct
10 Correct 629 ms 392608 KB Output is correct
11 Correct 678 ms 392788 KB Output is correct
12 Correct 632 ms 392784 KB Output is correct
13 Correct 625 ms 392784 KB Output is correct
14 Correct 626 ms 392696 KB Output is correct
15 Correct 645 ms 392800 KB Output is correct
16 Correct 745 ms 392532 KB Output is correct
17 Correct 704 ms 392788 KB Output is correct
18 Correct 638 ms 392784 KB Output is correct
19 Correct 670 ms 392692 KB Output is correct
20 Correct 682 ms 392604 KB Output is correct
21 Correct 679 ms 392788 KB Output is correct
22 Correct 672 ms 392612 KB Output is correct
23 Correct 665 ms 392772 KB Output is correct
24 Correct 661 ms 392784 KB Output is correct
25 Correct 648 ms 392632 KB Output is correct
26 Correct 622 ms 392784 KB Output is correct
27 Correct 637 ms 392792 KB Output is correct
28 Correct 702 ms 392532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 624 ms 392652 KB Output is correct
2 Correct 648 ms 392784 KB Output is correct
3 Correct 636 ms 392788 KB Output is correct
4 Correct 636 ms 392692 KB Output is correct
5 Correct 644 ms 392596 KB Output is correct
6 Correct 646 ms 392764 KB Output is correct
7 Correct 676 ms 392564 KB Output is correct
8 Correct 670 ms 392788 KB Output is correct
9 Correct 721 ms 392632 KB Output is correct
10 Correct 629 ms 392608 KB Output is correct
11 Correct 678 ms 392788 KB Output is correct
12 Correct 632 ms 392784 KB Output is correct
13 Correct 625 ms 392784 KB Output is correct
14 Correct 626 ms 392696 KB Output is correct
15 Correct 645 ms 392800 KB Output is correct
16 Correct 745 ms 392532 KB Output is correct
17 Correct 704 ms 392788 KB Output is correct
18 Correct 638 ms 392784 KB Output is correct
19 Correct 670 ms 392692 KB Output is correct
20 Correct 682 ms 392604 KB Output is correct
21 Correct 679 ms 392788 KB Output is correct
22 Correct 672 ms 392612 KB Output is correct
23 Correct 665 ms 392772 KB Output is correct
24 Correct 661 ms 392784 KB Output is correct
25 Correct 648 ms 392632 KB Output is correct
26 Correct 622 ms 392784 KB Output is correct
27 Correct 637 ms 392792 KB Output is correct
28 Correct 702 ms 392532 KB Output is correct
29 Correct 651 ms 392788 KB Output is correct
30 Correct 679 ms 392760 KB Output is correct
31 Correct 635 ms 392784 KB Output is correct
32 Correct 615 ms 397468 KB Output is correct
33 Correct 603 ms 392584 KB Output is correct
34 Correct 632 ms 392780 KB Output is correct
35 Correct 649 ms 392556 KB Output is correct
36 Correct 979 ms 392588 KB Output is correct
37 Correct 614 ms 392588 KB Output is correct
38 Correct 597 ms 393040 KB Output is correct
39 Correct 602 ms 394580 KB Output is correct
40 Correct 618 ms 398292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 8792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 8792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 624 ms 392652 KB Output is correct
2 Correct 648 ms 392784 KB Output is correct
3 Correct 636 ms 392788 KB Output is correct
4 Correct 636 ms 392692 KB Output is correct
5 Correct 644 ms 392596 KB Output is correct
6 Correct 646 ms 392764 KB Output is correct
7 Correct 676 ms 392564 KB Output is correct
8 Correct 670 ms 392788 KB Output is correct
9 Correct 721 ms 392632 KB Output is correct
10 Correct 629 ms 392608 KB Output is correct
11 Correct 678 ms 392788 KB Output is correct
12 Correct 632 ms 392784 KB Output is correct
13 Correct 625 ms 392784 KB Output is correct
14 Correct 626 ms 392696 KB Output is correct
15 Correct 645 ms 392800 KB Output is correct
16 Correct 745 ms 392532 KB Output is correct
17 Correct 704 ms 392788 KB Output is correct
18 Correct 638 ms 392784 KB Output is correct
19 Correct 670 ms 392692 KB Output is correct
20 Correct 682 ms 392604 KB Output is correct
21 Correct 679 ms 392788 KB Output is correct
22 Correct 672 ms 392612 KB Output is correct
23 Correct 665 ms 392772 KB Output is correct
24 Correct 661 ms 392784 KB Output is correct
25 Correct 648 ms 392632 KB Output is correct
26 Correct 622 ms 392784 KB Output is correct
27 Correct 637 ms 392792 KB Output is correct
28 Correct 702 ms 392532 KB Output is correct
29 Correct 651 ms 392788 KB Output is correct
30 Correct 679 ms 392760 KB Output is correct
31 Correct 635 ms 392784 KB Output is correct
32 Correct 615 ms 397468 KB Output is correct
33 Correct 603 ms 392584 KB Output is correct
34 Correct 632 ms 392780 KB Output is correct
35 Correct 649 ms 392556 KB Output is correct
36 Correct 979 ms 392588 KB Output is correct
37 Correct 614 ms 392588 KB Output is correct
38 Correct 597 ms 393040 KB Output is correct
39 Correct 602 ms 394580 KB Output is correct
40 Correct 618 ms 398292 KB Output is correct
41 Runtime error 5 ms 604 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -