답안 #965142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
965142 2024-04-18T07:41:39 Z phoenix0423 Cell Automaton (JOI23_cell) C++17
4 / 100
59 ms 8920 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
#define lowbit(x) x&-x
const int maxn = 1000 + 5;
const int INF = 1e18;
int dist[maxn][maxn];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int n, q;

void sol1(vector<pll> e){
    queue<pll> qq;
    for(int i = 0; i < maxn; i++) for(int j = 0; j < maxn; j++) dist[i][j] = INF;
    for(auto [x, y] : e){
        x += maxn / 2, y += maxn / 2;
        dist[x][y] = 0;
        qq.push({x, y});
    }
    vector<int> ans(maxn * 2);
    ans[0] = e.size();
    auto inbound = [&](int x, int y) -> bool {
        return x >= 0 && y >= 0 && x < maxn && y < maxn;
    };
    while(!qq.empty()){
        auto [x, y] = qq.front(); qq.pop();
        for(int d = 0; d < 4; d++){
            int xx = x + dx[d], yy = y + dy[d];
            if(!inbound(xx, yy) || dist[xx][yy] < INF) continue;
            dist[xx][yy] = dist[x][y] + 1;
            ans[dist[xx][yy]] += 1;
            qq.push({xx, yy});
        }
    }
    for(int i = 0; i < q; i++){
        int t;
        cin>>t;
        cout<<ans[t]<<"\n";
    }
    return;
}

signed main(void){
    // fastio;
    cin>>n>>q;
    int mx = 0;
    vector<pll> e;
    for(int i = 0; i < n; i++){
        int x, y;
        cin>>x>>y;
        mx = max(mx, max(abs(x), abs(y)));
        e.pb({x, y});
    }
    if(mx <= 1000){
        sol1(e);
        return 0;
    }


}
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8280 KB Output is correct
2 Correct 12 ms 8284 KB Output is correct
3 Correct 12 ms 8536 KB Output is correct
4 Correct 12 ms 8284 KB Output is correct
5 Correct 16 ms 8380 KB Output is correct
6 Correct 11 ms 8392 KB Output is correct
7 Correct 11 ms 8284 KB Output is correct
8 Correct 14 ms 8920 KB Output is correct
9 Correct 12 ms 8388 KB Output is correct
10 Correct 11 ms 8280 KB Output is correct
11 Correct 11 ms 8284 KB Output is correct
12 Correct 12 ms 8284 KB Output is correct
13 Correct 13 ms 8284 KB Output is correct
14 Correct 18 ms 8284 KB Output is correct
15 Correct 12 ms 8284 KB Output is correct
16 Correct 12 ms 8284 KB Output is correct
17 Correct 13 ms 8284 KB Output is correct
18 Correct 13 ms 8280 KB Output is correct
19 Correct 11 ms 8284 KB Output is correct
20 Correct 11 ms 8284 KB Output is correct
21 Correct 14 ms 8284 KB Output is correct
22 Correct 12 ms 8284 KB Output is correct
23 Correct 16 ms 8356 KB Output is correct
24 Correct 12 ms 8396 KB Output is correct
25 Correct 12 ms 8284 KB Output is correct
26 Correct 11 ms 8284 KB Output is correct
27 Correct 19 ms 8392 KB Output is correct
28 Correct 12 ms 8284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8280 KB Output is correct
2 Correct 12 ms 8284 KB Output is correct
3 Correct 12 ms 8536 KB Output is correct
4 Correct 12 ms 8284 KB Output is correct
5 Correct 16 ms 8380 KB Output is correct
6 Correct 11 ms 8392 KB Output is correct
7 Correct 11 ms 8284 KB Output is correct
8 Correct 14 ms 8920 KB Output is correct
9 Correct 12 ms 8388 KB Output is correct
10 Correct 11 ms 8280 KB Output is correct
11 Correct 11 ms 8284 KB Output is correct
12 Correct 12 ms 8284 KB Output is correct
13 Correct 13 ms 8284 KB Output is correct
14 Correct 18 ms 8284 KB Output is correct
15 Correct 12 ms 8284 KB Output is correct
16 Correct 12 ms 8284 KB Output is correct
17 Correct 13 ms 8284 KB Output is correct
18 Correct 13 ms 8280 KB Output is correct
19 Correct 11 ms 8284 KB Output is correct
20 Correct 11 ms 8284 KB Output is correct
21 Correct 14 ms 8284 KB Output is correct
22 Correct 12 ms 8284 KB Output is correct
23 Correct 16 ms 8356 KB Output is correct
24 Correct 12 ms 8396 KB Output is correct
25 Correct 12 ms 8284 KB Output is correct
26 Correct 11 ms 8284 KB Output is correct
27 Correct 19 ms 8392 KB Output is correct
28 Correct 12 ms 8284 KB Output is correct
29 Incorrect 15 ms 8284 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 4144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 4144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 8280 KB Output is correct
2 Correct 12 ms 8284 KB Output is correct
3 Correct 12 ms 8536 KB Output is correct
4 Correct 12 ms 8284 KB Output is correct
5 Correct 16 ms 8380 KB Output is correct
6 Correct 11 ms 8392 KB Output is correct
7 Correct 11 ms 8284 KB Output is correct
8 Correct 14 ms 8920 KB Output is correct
9 Correct 12 ms 8388 KB Output is correct
10 Correct 11 ms 8280 KB Output is correct
11 Correct 11 ms 8284 KB Output is correct
12 Correct 12 ms 8284 KB Output is correct
13 Correct 13 ms 8284 KB Output is correct
14 Correct 18 ms 8284 KB Output is correct
15 Correct 12 ms 8284 KB Output is correct
16 Correct 12 ms 8284 KB Output is correct
17 Correct 13 ms 8284 KB Output is correct
18 Correct 13 ms 8280 KB Output is correct
19 Correct 11 ms 8284 KB Output is correct
20 Correct 11 ms 8284 KB Output is correct
21 Correct 14 ms 8284 KB Output is correct
22 Correct 12 ms 8284 KB Output is correct
23 Correct 16 ms 8356 KB Output is correct
24 Correct 12 ms 8396 KB Output is correct
25 Correct 12 ms 8284 KB Output is correct
26 Correct 11 ms 8284 KB Output is correct
27 Correct 19 ms 8392 KB Output is correct
28 Correct 12 ms 8284 KB Output is correct
29 Incorrect 15 ms 8284 KB Output isn't correct
30 Halted 0 ms 0 KB -