답안 #810920

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
810920 2023-08-06T17:29:45 Z taher Cell Automaton (JOI23_cell) C++17
16 / 100
8000 ms 339972 KB
#include <bits/stdc++.h>

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<array<int, 2>> a(n);

  set<array<int, 2>> black, gray;

  for (int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1];
    black.insert({a[i][0], a[i][1]});
  }

  auto Advance = [&]() {
    set<array<int, 2>> nblack;
    for (auto cell : black) {
      int x = cell[0];
      int y = cell[1];

      for (int it = 0; it < 4; it++) {
        int nx = x + dx[it];
        int ny = y + dy[it];
        if (!gray.count({nx, ny}) && !black.count({nx, ny})) {
          nblack.insert({nx, ny});
        }
      }
    }
    swap(gray, black);
    swap(black, nblack);
  };

  int current_t = 0;

  auto SimulateTo = [&](int t) {
    while (current_t < t) {
      Advance();
      current_t++;
    }

    return (int) black.size();
  };

  for (int i = 0; i < m; i++) {
    int timestamp;
    cin >> timestamp;

    cout << SimulateTo(timestamp) << '\n';
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 360 KB Output is correct
3 Correct 12 ms 400 KB Output is correct
4 Correct 15 ms 452 KB Output is correct
5 Correct 4 ms 352 KB Output is correct
6 Correct 6 ms 468 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 17 ms 848 KB Output is correct
9 Correct 14 ms 444 KB Output is correct
10 Correct 14 ms 340 KB Output is correct
11 Correct 13 ms 340 KB Output is correct
12 Correct 19 ms 740 KB Output is correct
13 Correct 17 ms 724 KB Output is correct
14 Correct 17 ms 736 KB Output is correct
15 Correct 17 ms 708 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 360 KB Output is correct
3 Correct 12 ms 400 KB Output is correct
4 Correct 15 ms 452 KB Output is correct
5 Correct 4 ms 352 KB Output is correct
6 Correct 6 ms 468 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 17 ms 848 KB Output is correct
9 Correct 14 ms 444 KB Output is correct
10 Correct 14 ms 340 KB Output is correct
11 Correct 13 ms 340 KB Output is correct
12 Correct 19 ms 740 KB Output is correct
13 Correct 17 ms 724 KB Output is correct
14 Correct 17 ms 736 KB Output is correct
15 Correct 17 ms 708 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 992 ms 968 KB Output is correct
30 Correct 1626 ms 992 KB Output is correct
31 Correct 2596 ms 1352 KB Output is correct
32 Correct 4188 ms 35916 KB Output is correct
33 Correct 1652 ms 1096 KB Output is correct
34 Correct 1958 ms 1232 KB Output is correct
35 Correct 1974 ms 1072 KB Output is correct
36 Correct 233 ms 612 KB Output is correct
37 Correct 228 ms 536 KB Output is correct
38 Correct 3752 ms 5644 KB Output is correct
39 Correct 4043 ms 17024 KB Output is correct
40 Correct 4108 ms 40996 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 8064 ms 339972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 8064 ms 339972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 8052 ms 2968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 8052 ms 2968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 5 ms 360 KB Output is correct
3 Correct 12 ms 400 KB Output is correct
4 Correct 15 ms 452 KB Output is correct
5 Correct 4 ms 352 KB Output is correct
6 Correct 6 ms 468 KB Output is correct
7 Correct 6 ms 340 KB Output is correct
8 Correct 17 ms 848 KB Output is correct
9 Correct 14 ms 444 KB Output is correct
10 Correct 14 ms 340 KB Output is correct
11 Correct 13 ms 340 KB Output is correct
12 Correct 19 ms 740 KB Output is correct
13 Correct 17 ms 724 KB Output is correct
14 Correct 17 ms 736 KB Output is correct
15 Correct 17 ms 708 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 992 ms 968 KB Output is correct
30 Correct 1626 ms 992 KB Output is correct
31 Correct 2596 ms 1352 KB Output is correct
32 Correct 4188 ms 35916 KB Output is correct
33 Correct 1652 ms 1096 KB Output is correct
34 Correct 1958 ms 1232 KB Output is correct
35 Correct 1974 ms 1072 KB Output is correct
36 Correct 233 ms 612 KB Output is correct
37 Correct 228 ms 536 KB Output is correct
38 Correct 3752 ms 5644 KB Output is correct
39 Correct 4043 ms 17024 KB Output is correct
40 Correct 4108 ms 40996 KB Output is correct
41 Execution timed out 8064 ms 339972 KB Time limit exceeded
42 Halted 0 ms 0 KB -