Submission #813354

# Submission time Handle Problem Language Result Execution time Memory
813354 2023-08-07T16:17:34 Z arnold518 Cell Automaton (JOI23_cell) C++17
4 / 100
146 ms 51020 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5;
const int MAXM = 5e5;

int N, M;
pii A[MAXN+10];
int B[MAXM+10];

int P[3010][3010];

const int dy[]={-1, 1, 0, 0};
const int dx[]={0, 0, -1, 1};

int ans[1010];

int main()
{
    scanf("%d%d", &N, &M);
    for(int i=1; i<=N; i++) scanf("%d%d", &A[i].first, &A[i].second);
    for(int i=1; i<=M; i++) scanf("%d", &B[i]);

    queue<pii> Q;
    for(int i=1; i<=N; i++)
    {
        P[A[i].first+1000][A[i].second+1000]=1;
        Q.push({A[i].first+1000, A[i].second+1000});
    }

    while(!Q.empty())
    {
        pii now=Q.front(); Q.pop();
        ans[P[now.first][now.second]-1]++;
        if(P[now.first][now.second]>B[M]+1) continue;
        for(int i=0; i<4; i++)
        {
            int ny=now.first+dy[i], nx=now.second+dx[i];
            if(P[ny][nx]) continue;
            P[ny][nx]=P[now.first][now.second]+1;
            Q.push({ny, nx});
        }
    }

    for(int i=1; i<=M; i++) printf("%d\n", ans[B[i]]);
}

Compilation message

cell.cpp: In function 'int main()':
cell.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     scanf("%d%d", &N, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~
cell.cpp:25:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     for(int i=1; i<=N; i++) scanf("%d%d", &A[i].first, &A[i].second);
      |                             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cell.cpp:26:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     for(int i=1; i<=M; i++) scanf("%d", &B[i]);
      |                             ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 2 ms 980 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 2 ms 1236 KB Output is correct
14 Correct 2 ms 1236 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 1 ms 732 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 2 ms 980 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 2 ms 1236 KB Output is correct
14 Correct 2 ms 1236 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 1 ms 732 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 53 ms 16504 KB Output is correct
30 Correct 92 ms 22664 KB Output is correct
31 Correct 146 ms 30312 KB Output is correct
32 Runtime error 131 ms 51020 KB Execution killed with signal 11
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 2012 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 2012 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 852 KB Output is correct
6 Correct 2 ms 980 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 1 ms 1236 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 2 ms 1236 KB Output is correct
13 Correct 2 ms 1236 KB Output is correct
14 Correct 2 ms 1236 KB Output is correct
15 Correct 1 ms 1236 KB Output is correct
16 Correct 1 ms 724 KB Output is correct
17 Correct 1 ms 732 KB Output is correct
18 Correct 1 ms 724 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 724 KB Output is correct
21 Correct 1 ms 724 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 1 ms 724 KB Output is correct
25 Correct 1 ms 724 KB Output is correct
26 Correct 1 ms 724 KB Output is correct
27 Correct 1 ms 724 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 53 ms 16504 KB Output is correct
30 Correct 92 ms 22664 KB Output is correct
31 Correct 146 ms 30312 KB Output is correct
32 Runtime error 131 ms 51020 KB Execution killed with signal 11
33 Halted 0 ms 0 KB -