# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1045807 |
2024-08-06T07:50:59 Z |
우민규(#11015) |
Cell Automaton (JOI23_cell) |
C++17 |
|
400 ms |
198996 KB |
#include <bits/stdc++.h>
using namespace std;
const int gsize = 5000;
const int offset = 2500;
int n, q;
int dist[gsize][gsize];
queue<pair<int, pair<int, int>>> qu;
int dist_cnt[2 * gsize];
void solve() {
for (int i = 0; i < gsize; ++i) fill(dist[i], dist[i] + gsize, INT_MAX);
cin >> n >> q;
for (int i = 0; i < n; ++i) {
int x, y;
cin >> x >> y;
x += offset, y += offset;
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 >= gsize || xx < 0 || xx >= gsize) continue;
if (dist[yy][xx] != INT_MAX) continue;
dist[yy][xx] = d + 1;
qu.push({d + 1, {yy, xx}});
}
}
for (int i = 0; i < gsize; ++i) for (int j = 0; j < gsize; ++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:48:9: warning: unused variable 't' [-Wunused-variable]
48 | int t = 1;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
268 ms |
98388 KB |
Output is correct |
2 |
Correct |
280 ms |
98596 KB |
Output is correct |
3 |
Correct |
280 ms |
98388 KB |
Output is correct |
4 |
Correct |
266 ms |
98332 KB |
Output is correct |
5 |
Correct |
275 ms |
98328 KB |
Output is correct |
6 |
Correct |
309 ms |
98388 KB |
Output is correct |
7 |
Correct |
277 ms |
98388 KB |
Output is correct |
8 |
Correct |
274 ms |
98396 KB |
Output is correct |
9 |
Correct |
268 ms |
98384 KB |
Output is correct |
10 |
Correct |
290 ms |
98336 KB |
Output is correct |
11 |
Correct |
271 ms |
98388 KB |
Output is correct |
12 |
Correct |
274 ms |
98384 KB |
Output is correct |
13 |
Correct |
277 ms |
98384 KB |
Output is correct |
14 |
Correct |
278 ms |
98392 KB |
Output is correct |
15 |
Correct |
283 ms |
98388 KB |
Output is correct |
16 |
Correct |
375 ms |
98252 KB |
Output is correct |
17 |
Correct |
323 ms |
98388 KB |
Output is correct |
18 |
Correct |
400 ms |
98320 KB |
Output is correct |
19 |
Correct |
293 ms |
98644 KB |
Output is correct |
20 |
Correct |
276 ms |
98388 KB |
Output is correct |
21 |
Correct |
317 ms |
98384 KB |
Output is correct |
22 |
Correct |
351 ms |
98384 KB |
Output is correct |
23 |
Correct |
270 ms |
98344 KB |
Output is correct |
24 |
Correct |
274 ms |
98388 KB |
Output is correct |
25 |
Correct |
265 ms |
98388 KB |
Output is correct |
26 |
Correct |
273 ms |
98256 KB |
Output is correct |
27 |
Correct |
274 ms |
98348 KB |
Output is correct |
28 |
Correct |
269 ms |
98344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
268 ms |
98388 KB |
Output is correct |
2 |
Correct |
280 ms |
98596 KB |
Output is correct |
3 |
Correct |
280 ms |
98388 KB |
Output is correct |
4 |
Correct |
266 ms |
98332 KB |
Output is correct |
5 |
Correct |
275 ms |
98328 KB |
Output is correct |
6 |
Correct |
309 ms |
98388 KB |
Output is correct |
7 |
Correct |
277 ms |
98388 KB |
Output is correct |
8 |
Correct |
274 ms |
98396 KB |
Output is correct |
9 |
Correct |
268 ms |
98384 KB |
Output is correct |
10 |
Correct |
290 ms |
98336 KB |
Output is correct |
11 |
Correct |
271 ms |
98388 KB |
Output is correct |
12 |
Correct |
274 ms |
98384 KB |
Output is correct |
13 |
Correct |
277 ms |
98384 KB |
Output is correct |
14 |
Correct |
278 ms |
98392 KB |
Output is correct |
15 |
Correct |
283 ms |
98388 KB |
Output is correct |
16 |
Correct |
375 ms |
98252 KB |
Output is correct |
17 |
Correct |
323 ms |
98388 KB |
Output is correct |
18 |
Correct |
400 ms |
98320 KB |
Output is correct |
19 |
Correct |
293 ms |
98644 KB |
Output is correct |
20 |
Correct |
276 ms |
98388 KB |
Output is correct |
21 |
Correct |
317 ms |
98384 KB |
Output is correct |
22 |
Correct |
351 ms |
98384 KB |
Output is correct |
23 |
Correct |
270 ms |
98344 KB |
Output is correct |
24 |
Correct |
274 ms |
98388 KB |
Output is correct |
25 |
Correct |
265 ms |
98388 KB |
Output is correct |
26 |
Correct |
273 ms |
98256 KB |
Output is correct |
27 |
Correct |
274 ms |
98348 KB |
Output is correct |
28 |
Correct |
269 ms |
98344 KB |
Output is correct |
29 |
Correct |
270 ms |
98384 KB |
Output is correct |
30 |
Correct |
284 ms |
98388 KB |
Output is correct |
31 |
Correct |
311 ms |
98264 KB |
Output is correct |
32 |
Correct |
335 ms |
101968 KB |
Output is correct |
33 |
Correct |
277 ms |
98384 KB |
Output is correct |
34 |
Correct |
291 ms |
98344 KB |
Output is correct |
35 |
Correct |
276 ms |
98388 KB |
Output is correct |
36 |
Correct |
395 ms |
98352 KB |
Output is correct |
37 |
Correct |
371 ms |
98384 KB |
Output is correct |
38 |
Correct |
319 ms |
98648 KB |
Output is correct |
39 |
Correct |
315 ms |
99676 KB |
Output is correct |
40 |
Correct |
345 ms |
103232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
71 ms |
198996 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
71 ms |
198996 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
73 ms |
198972 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
73 ms |
198972 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
268 ms |
98388 KB |
Output is correct |
2 |
Correct |
280 ms |
98596 KB |
Output is correct |
3 |
Correct |
280 ms |
98388 KB |
Output is correct |
4 |
Correct |
266 ms |
98332 KB |
Output is correct |
5 |
Correct |
275 ms |
98328 KB |
Output is correct |
6 |
Correct |
309 ms |
98388 KB |
Output is correct |
7 |
Correct |
277 ms |
98388 KB |
Output is correct |
8 |
Correct |
274 ms |
98396 KB |
Output is correct |
9 |
Correct |
268 ms |
98384 KB |
Output is correct |
10 |
Correct |
290 ms |
98336 KB |
Output is correct |
11 |
Correct |
271 ms |
98388 KB |
Output is correct |
12 |
Correct |
274 ms |
98384 KB |
Output is correct |
13 |
Correct |
277 ms |
98384 KB |
Output is correct |
14 |
Correct |
278 ms |
98392 KB |
Output is correct |
15 |
Correct |
283 ms |
98388 KB |
Output is correct |
16 |
Correct |
375 ms |
98252 KB |
Output is correct |
17 |
Correct |
323 ms |
98388 KB |
Output is correct |
18 |
Correct |
400 ms |
98320 KB |
Output is correct |
19 |
Correct |
293 ms |
98644 KB |
Output is correct |
20 |
Correct |
276 ms |
98388 KB |
Output is correct |
21 |
Correct |
317 ms |
98384 KB |
Output is correct |
22 |
Correct |
351 ms |
98384 KB |
Output is correct |
23 |
Correct |
270 ms |
98344 KB |
Output is correct |
24 |
Correct |
274 ms |
98388 KB |
Output is correct |
25 |
Correct |
265 ms |
98388 KB |
Output is correct |
26 |
Correct |
273 ms |
98256 KB |
Output is correct |
27 |
Correct |
274 ms |
98348 KB |
Output is correct |
28 |
Correct |
269 ms |
98344 KB |
Output is correct |
29 |
Correct |
270 ms |
98384 KB |
Output is correct |
30 |
Correct |
284 ms |
98388 KB |
Output is correct |
31 |
Correct |
311 ms |
98264 KB |
Output is correct |
32 |
Correct |
335 ms |
101968 KB |
Output is correct |
33 |
Correct |
277 ms |
98384 KB |
Output is correct |
34 |
Correct |
291 ms |
98344 KB |
Output is correct |
35 |
Correct |
276 ms |
98388 KB |
Output is correct |
36 |
Correct |
395 ms |
98352 KB |
Output is correct |
37 |
Correct |
371 ms |
98384 KB |
Output is correct |
38 |
Correct |
319 ms |
98648 KB |
Output is correct |
39 |
Correct |
315 ms |
99676 KB |
Output is correct |
40 |
Correct |
345 ms |
103232 KB |
Output is correct |
41 |
Runtime error |
71 ms |
198996 KB |
Execution killed with signal 11 |
42 |
Halted |
0 ms |
0 KB |
- |