답안 #1045801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045801 2024-08-06T07:48:03 Z 우민규(#11015) Cell Automaton (JOI23_cell) C++17
4 / 100
250 ms 127568 KB
#include <bits/stdc++.h>
using namespace std;

int n, q;

int dist[4000][4000];
queue<pair<int, pair<int, int>>> qu;
int dist_cnt[8000];

void solve() {
    for (int i = 0; i < 4000; ++i) fill(dist[i], dist[i] + 4000, INT_MAX);
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        x += 1300, y += 1300;
        dist[y][x] = 0;
        qu.push({0, {y, x}});
    }
    while (!qu.empty()) {
        auto [d, loc] = qu.front();
        qu.pop();
        auto [y, x] = loc;
        for (auto [yy, xx] : initializer_list<pair<int, int>>{{y-1, x}, {y+1, x}, {y,x-1}, {y,x+1}}) {
            if (yy < 0 || yy >= 4000 || xx < 0 || xx >= 4000) continue;
            if (dist[yy][xx] != INT_MAX) continue;
            dist[yy][xx] = d + 1;
            qu.push({d + 1, {yy, xx}});
        }
    }
    for (int i = 0; i < 4000; ++i) for (int j = 0; j < 4000; ++j) {
        if (dist[i][j] != INT_MAX) {
            dist_cnt[dist[i][j]] += 1;
        }
    }
    while (q--) {
        int t;
        cin >> t;
        cout << dist_cnt[t] << "\n";
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    solve();
}

Compilation message

cell.cpp: In function 'int main()':
cell.cpp:45:9: warning: unused variable 't' [-Wunused-variable]
   45 |     int t = 1;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 63124 KB Output is correct
2 Correct 202 ms 63116 KB Output is correct
3 Correct 177 ms 63324 KB Output is correct
4 Correct 172 ms 63108 KB Output is correct
5 Correct 199 ms 63104 KB Output is correct
6 Correct 204 ms 63068 KB Output is correct
7 Correct 167 ms 63068 KB Output is correct
8 Correct 222 ms 63252 KB Output is correct
9 Correct 178 ms 63104 KB Output is correct
10 Correct 167 ms 63116 KB Output is correct
11 Correct 175 ms 63116 KB Output is correct
12 Correct 179 ms 63132 KB Output is correct
13 Correct 200 ms 63140 KB Output is correct
14 Correct 221 ms 63128 KB Output is correct
15 Correct 177 ms 63068 KB Output is correct
16 Correct 250 ms 63064 KB Output is correct
17 Correct 218 ms 63132 KB Output is correct
18 Correct 235 ms 63128 KB Output is correct
19 Correct 167 ms 63320 KB Output is correct
20 Correct 164 ms 63064 KB Output is correct
21 Correct 193 ms 63120 KB Output is correct
22 Correct 205 ms 63128 KB Output is correct
23 Correct 172 ms 63068 KB Output is correct
24 Correct 163 ms 63068 KB Output is correct
25 Correct 181 ms 63124 KB Output is correct
26 Correct 173 ms 63064 KB Output is correct
27 Correct 195 ms 63124 KB Output is correct
28 Correct 218 ms 63072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 63124 KB Output is correct
2 Correct 202 ms 63116 KB Output is correct
3 Correct 177 ms 63324 KB Output is correct
4 Correct 172 ms 63108 KB Output is correct
5 Correct 199 ms 63104 KB Output is correct
6 Correct 204 ms 63068 KB Output is correct
7 Correct 167 ms 63068 KB Output is correct
8 Correct 222 ms 63252 KB Output is correct
9 Correct 178 ms 63104 KB Output is correct
10 Correct 167 ms 63116 KB Output is correct
11 Correct 175 ms 63116 KB Output is correct
12 Correct 179 ms 63132 KB Output is correct
13 Correct 200 ms 63140 KB Output is correct
14 Correct 221 ms 63128 KB Output is correct
15 Correct 177 ms 63068 KB Output is correct
16 Correct 250 ms 63064 KB Output is correct
17 Correct 218 ms 63132 KB Output is correct
18 Correct 235 ms 63128 KB Output is correct
19 Correct 167 ms 63320 KB Output is correct
20 Correct 164 ms 63064 KB Output is correct
21 Correct 193 ms 63120 KB Output is correct
22 Correct 205 ms 63128 KB Output is correct
23 Correct 172 ms 63068 KB Output is correct
24 Correct 163 ms 63068 KB Output is correct
25 Correct 181 ms 63124 KB Output is correct
26 Correct 173 ms 63064 KB Output is correct
27 Correct 195 ms 63124 KB Output is correct
28 Correct 218 ms 63072 KB Output is correct
29 Correct 168 ms 63068 KB Output is correct
30 Correct 171 ms 63068 KB Output is correct
31 Correct 195 ms 63152 KB Output is correct
32 Incorrect 221 ms 67600 KB Output isn't correct
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 52 ms 127568 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 52 ms 127568 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 53 ms 127428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 53 ms 127428 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 170 ms 63124 KB Output is correct
2 Correct 202 ms 63116 KB Output is correct
3 Correct 177 ms 63324 KB Output is correct
4 Correct 172 ms 63108 KB Output is correct
5 Correct 199 ms 63104 KB Output is correct
6 Correct 204 ms 63068 KB Output is correct
7 Correct 167 ms 63068 KB Output is correct
8 Correct 222 ms 63252 KB Output is correct
9 Correct 178 ms 63104 KB Output is correct
10 Correct 167 ms 63116 KB Output is correct
11 Correct 175 ms 63116 KB Output is correct
12 Correct 179 ms 63132 KB Output is correct
13 Correct 200 ms 63140 KB Output is correct
14 Correct 221 ms 63128 KB Output is correct
15 Correct 177 ms 63068 KB Output is correct
16 Correct 250 ms 63064 KB Output is correct
17 Correct 218 ms 63132 KB Output is correct
18 Correct 235 ms 63128 KB Output is correct
19 Correct 167 ms 63320 KB Output is correct
20 Correct 164 ms 63064 KB Output is correct
21 Correct 193 ms 63120 KB Output is correct
22 Correct 205 ms 63128 KB Output is correct
23 Correct 172 ms 63068 KB Output is correct
24 Correct 163 ms 63068 KB Output is correct
25 Correct 181 ms 63124 KB Output is correct
26 Correct 173 ms 63064 KB Output is correct
27 Correct 195 ms 63124 KB Output is correct
28 Correct 218 ms 63072 KB Output is correct
29 Correct 168 ms 63068 KB Output is correct
30 Correct 171 ms 63068 KB Output is correct
31 Correct 195 ms 63152 KB Output is correct
32 Incorrect 221 ms 67600 KB Output isn't correct
33 Halted 0 ms 0 KB -