답안 #964511

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964511 2024-04-17T04:50:20 Z kilkuwu 화성 (APIO22_mars) C++17
54 / 100
319 ms 5476 KB
#include "mars.h"

#include <bits/stdc++.h>

std::pair<int, int> get_bounds(int i, int k, int n) {
  int left = i * (2 * n + 1) / (2 * (n - k) + 1);
  int right = (i + 1) * (2 * n + 1) / (2 * (n - k) + 1);
  return {left, right};
}


std::string solve(std::vector<std::string> g) {
  int n = g.size();

  std::vector<int> used(n * n);

  auto id = [&](int x, int y) {
    return x * n + y;
  };

  auto dfs = [&](auto self, int x, int y) -> void {
    used[id(x, y)] = 1;
    if (x - 1 >= 0) {
      if (!used[id(x - 1, y)] && g[x - 1][y] == '1') {
        self(self, x - 1, y);
      } 
    }

    if (x + 1 < n) {
      if (!used[id(x + 1, y)] && g[x + 1][y] == '1') {
        self(self, x + 1, y);
      } 
    }

    if (y - 1 >= 0) {
      if (!used[id(x, y - 1)] && g[x][y - 1] == '1') {
        self(self, x, y - 1);
      } 
    }

    if (y + 1 < n) {
      if (!used[id(x, y + 1)] && g[x][y + 1] == '1') {
        self(self, x, y + 1);
      } 
    }
  };

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!used[i * n + j] && g[i][j] == '1') {
        dfs(dfs, i, j);
        ans++;
      }
    }
  }

  std::string res;
  while (ans) {
    res.push_back((ans & 1) + '0');
    ans >>= 1;
  }

  while (res.size() < 100) {
    res.push_back('0');
  }
  return res;
}

std::string process(std::vector<std::vector<std::string>> a, int xx, int yy, int k, int n) {
  std::vector<std::string> g(2 * n + 1, std::string(2 * n + 1, '0'));

  auto regen = [&](std::string s, int x, int y) {
    auto [lx, rx] = get_bounds(x, k, n);
    auto [ly, ry] = get_bounds(y, k, n);

    for (int i = lx; i < rx; i++) {
      for (int j = ly; j < ry; j++) {
        int u = i - lx;
        int v = j - ly;
        g[i][j] = s[u * (ry - ly) + v];
      }
    }
  };

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      regen(a[i][j], xx + i, yy + j);
    }
  }


  if (k == n - 1) {
    return solve(g);
  }

  auto [lx, rx] = get_bounds(xx, k + 1, n);
  auto [ly, ry] = get_bounds(yy, k + 1, n);

  std::string res(100, '0');
  for (int i = lx; i < rx; i++) {
    for (int j = ly; j < ry; j++) {
      int u = i - lx;
      int v = j - ly;
      res[u * (ry - ly) + v] = g[i][j];
    }
  }

  return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
14 Correct 19 ms 4168 KB Output is correct
15 Correct 24 ms 3904 KB Output is correct
16 Correct 26 ms 4044 KB Output is correct
17 Correct 30 ms 4344 KB Output is correct
18 Correct 26 ms 4220 KB Output is correct
19 Correct 24 ms 4040 KB Output is correct
20 Correct 28 ms 4012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
14 Correct 19 ms 4168 KB Output is correct
15 Correct 24 ms 3904 KB Output is correct
16 Correct 26 ms 4044 KB Output is correct
17 Correct 30 ms 4344 KB Output is correct
18 Correct 26 ms 4220 KB Output is correct
19 Correct 24 ms 4040 KB Output is correct
20 Correct 28 ms 4012 KB Output is correct
21 Correct 41 ms 4408 KB Output is correct
22 Correct 60 ms 4264 KB Output is correct
23 Correct 61 ms 4132 KB Output is correct
24 Correct 53 ms 3948 KB Output is correct
25 Correct 62 ms 4436 KB Output is correct
26 Correct 61 ms 4336 KB Output is correct
27 Correct 62 ms 4200 KB Output is correct
28 Correct 65 ms 4120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
14 Correct 19 ms 4168 KB Output is correct
15 Correct 24 ms 3904 KB Output is correct
16 Correct 26 ms 4044 KB Output is correct
17 Correct 30 ms 4344 KB Output is correct
18 Correct 26 ms 4220 KB Output is correct
19 Correct 24 ms 4040 KB Output is correct
20 Correct 28 ms 4012 KB Output is correct
21 Correct 41 ms 4408 KB Output is correct
22 Correct 60 ms 4264 KB Output is correct
23 Correct 61 ms 4132 KB Output is correct
24 Correct 53 ms 3948 KB Output is correct
25 Correct 62 ms 4436 KB Output is correct
26 Correct 61 ms 4336 KB Output is correct
27 Correct 62 ms 4200 KB Output is correct
28 Correct 65 ms 4120 KB Output is correct
29 Correct 86 ms 4040 KB Output is correct
30 Correct 110 ms 4228 KB Output is correct
31 Correct 119 ms 4128 KB Output is correct
32 Correct 106 ms 4536 KB Output is correct
33 Correct 123 ms 4092 KB Output is correct
34 Correct 107 ms 4784 KB Output is correct
35 Correct 111 ms 4152 KB Output is correct
36 Correct 108 ms 4004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
14 Correct 19 ms 4168 KB Output is correct
15 Correct 24 ms 3904 KB Output is correct
16 Correct 26 ms 4044 KB Output is correct
17 Correct 30 ms 4344 KB Output is correct
18 Correct 26 ms 4220 KB Output is correct
19 Correct 24 ms 4040 KB Output is correct
20 Correct 28 ms 4012 KB Output is correct
21 Correct 41 ms 4408 KB Output is correct
22 Correct 60 ms 4264 KB Output is correct
23 Correct 61 ms 4132 KB Output is correct
24 Correct 53 ms 3948 KB Output is correct
25 Correct 62 ms 4436 KB Output is correct
26 Correct 61 ms 4336 KB Output is correct
27 Correct 62 ms 4200 KB Output is correct
28 Correct 65 ms 4120 KB Output is correct
29 Correct 86 ms 4040 KB Output is correct
30 Correct 110 ms 4228 KB Output is correct
31 Correct 119 ms 4128 KB Output is correct
32 Correct 106 ms 4536 KB Output is correct
33 Correct 123 ms 4092 KB Output is correct
34 Correct 107 ms 4784 KB Output is correct
35 Correct 111 ms 4152 KB Output is correct
36 Correct 108 ms 4004 KB Output is correct
37 Correct 147 ms 4216 KB Output is correct
38 Correct 200 ms 4504 KB Output is correct
39 Correct 198 ms 4924 KB Output is correct
40 Correct 201 ms 5088 KB Output is correct
41 Correct 209 ms 5420 KB Output is correct
42 Correct 194 ms 4768 KB Output is correct
43 Correct 192 ms 4628 KB Output is correct
44 Correct 196 ms 4868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
14 Correct 19 ms 4168 KB Output is correct
15 Correct 24 ms 3904 KB Output is correct
16 Correct 26 ms 4044 KB Output is correct
17 Correct 30 ms 4344 KB Output is correct
18 Correct 26 ms 4220 KB Output is correct
19 Correct 24 ms 4040 KB Output is correct
20 Correct 28 ms 4012 KB Output is correct
21 Correct 41 ms 4408 KB Output is correct
22 Correct 60 ms 4264 KB Output is correct
23 Correct 61 ms 4132 KB Output is correct
24 Correct 53 ms 3948 KB Output is correct
25 Correct 62 ms 4436 KB Output is correct
26 Correct 61 ms 4336 KB Output is correct
27 Correct 62 ms 4200 KB Output is correct
28 Correct 65 ms 4120 KB Output is correct
29 Correct 86 ms 4040 KB Output is correct
30 Correct 110 ms 4228 KB Output is correct
31 Correct 119 ms 4128 KB Output is correct
32 Correct 106 ms 4536 KB Output is correct
33 Correct 123 ms 4092 KB Output is correct
34 Correct 107 ms 4784 KB Output is correct
35 Correct 111 ms 4152 KB Output is correct
36 Correct 108 ms 4004 KB Output is correct
37 Correct 147 ms 4216 KB Output is correct
38 Correct 200 ms 4504 KB Output is correct
39 Correct 198 ms 4924 KB Output is correct
40 Correct 201 ms 5088 KB Output is correct
41 Correct 209 ms 5420 KB Output is correct
42 Correct 194 ms 4768 KB Output is correct
43 Correct 192 ms 4628 KB Output is correct
44 Correct 196 ms 4868 KB Output is correct
45 Correct 249 ms 4608 KB Output is correct
46 Correct 307 ms 5476 KB Output is correct
47 Correct 303 ms 4580 KB Output is correct
48 Correct 306 ms 5016 KB Output is correct
49 Correct 312 ms 4984 KB Output is correct
50 Correct 319 ms 4660 KB Output is correct
51 Correct 314 ms 5072 KB Output is correct
52 Correct 310 ms 5220 KB Output is correct
53 Correct 308 ms 4728 KB Output is correct
54 Correct 311 ms 4520 KB Output is correct
55 Correct 314 ms 4412 KB Output is correct
56 Correct 312 ms 4980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
14 Correct 19 ms 4168 KB Output is correct
15 Correct 24 ms 3904 KB Output is correct
16 Correct 26 ms 4044 KB Output is correct
17 Correct 30 ms 4344 KB Output is correct
18 Correct 26 ms 4220 KB Output is correct
19 Correct 24 ms 4040 KB Output is correct
20 Correct 28 ms 4012 KB Output is correct
21 Correct 41 ms 4408 KB Output is correct
22 Correct 60 ms 4264 KB Output is correct
23 Correct 61 ms 4132 KB Output is correct
24 Correct 53 ms 3948 KB Output is correct
25 Correct 62 ms 4436 KB Output is correct
26 Correct 61 ms 4336 KB Output is correct
27 Correct 62 ms 4200 KB Output is correct
28 Correct 65 ms 4120 KB Output is correct
29 Correct 86 ms 4040 KB Output is correct
30 Correct 110 ms 4228 KB Output is correct
31 Correct 119 ms 4128 KB Output is correct
32 Correct 106 ms 4536 KB Output is correct
33 Correct 123 ms 4092 KB Output is correct
34 Correct 107 ms 4784 KB Output is correct
35 Correct 111 ms 4152 KB Output is correct
36 Correct 108 ms 4004 KB Output is correct
37 Correct 147 ms 4216 KB Output is correct
38 Correct 200 ms 4504 KB Output is correct
39 Correct 198 ms 4924 KB Output is correct
40 Correct 201 ms 5088 KB Output is correct
41 Correct 209 ms 5420 KB Output is correct
42 Correct 194 ms 4768 KB Output is correct
43 Correct 192 ms 4628 KB Output is correct
44 Correct 196 ms 4868 KB Output is correct
45 Correct 249 ms 4608 KB Output is correct
46 Correct 307 ms 5476 KB Output is correct
47 Correct 303 ms 4580 KB Output is correct
48 Correct 306 ms 5016 KB Output is correct
49 Correct 312 ms 4984 KB Output is correct
50 Correct 319 ms 4660 KB Output is correct
51 Correct 314 ms 5072 KB Output is correct
52 Correct 310 ms 5220 KB Output is correct
53 Correct 308 ms 4728 KB Output is correct
54 Correct 311 ms 4520 KB Output is correct
55 Correct 314 ms 4412 KB Output is correct
56 Correct 312 ms 4980 KB Output is correct
57 Runtime error 52 ms 852 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
14 Correct 19 ms 4168 KB Output is correct
15 Correct 24 ms 3904 KB Output is correct
16 Correct 26 ms 4044 KB Output is correct
17 Correct 30 ms 4344 KB Output is correct
18 Correct 26 ms 4220 KB Output is correct
19 Correct 24 ms 4040 KB Output is correct
20 Correct 28 ms 4012 KB Output is correct
21 Correct 41 ms 4408 KB Output is correct
22 Correct 60 ms 4264 KB Output is correct
23 Correct 61 ms 4132 KB Output is correct
24 Correct 53 ms 3948 KB Output is correct
25 Correct 62 ms 4436 KB Output is correct
26 Correct 61 ms 4336 KB Output is correct
27 Correct 62 ms 4200 KB Output is correct
28 Correct 65 ms 4120 KB Output is correct
29 Correct 86 ms 4040 KB Output is correct
30 Correct 110 ms 4228 KB Output is correct
31 Correct 119 ms 4128 KB Output is correct
32 Correct 106 ms 4536 KB Output is correct
33 Correct 123 ms 4092 KB Output is correct
34 Correct 107 ms 4784 KB Output is correct
35 Correct 111 ms 4152 KB Output is correct
36 Correct 108 ms 4004 KB Output is correct
37 Correct 147 ms 4216 KB Output is correct
38 Correct 200 ms 4504 KB Output is correct
39 Correct 198 ms 4924 KB Output is correct
40 Correct 201 ms 5088 KB Output is correct
41 Correct 209 ms 5420 KB Output is correct
42 Correct 194 ms 4768 KB Output is correct
43 Correct 192 ms 4628 KB Output is correct
44 Correct 196 ms 4868 KB Output is correct
45 Correct 249 ms 4608 KB Output is correct
46 Correct 307 ms 5476 KB Output is correct
47 Correct 303 ms 4580 KB Output is correct
48 Correct 306 ms 5016 KB Output is correct
49 Correct 312 ms 4984 KB Output is correct
50 Correct 319 ms 4660 KB Output is correct
51 Correct 314 ms 5072 KB Output is correct
52 Correct 310 ms 5220 KB Output is correct
53 Correct 308 ms 4728 KB Output is correct
54 Correct 311 ms 4520 KB Output is correct
55 Correct 314 ms 4412 KB Output is correct
56 Correct 312 ms 4980 KB Output is correct
57 Runtime error 52 ms 852 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4116 KB Output is correct
2 Correct 3 ms 3688 KB Output is correct
3 Correct 8 ms 4136 KB Output is correct
4 Correct 6 ms 4192 KB Output is correct
5 Correct 7 ms 3784 KB Output is correct
6 Correct 4 ms 3688 KB Output is correct
7 Correct 8 ms 3788 KB Output is correct
8 Correct 8 ms 4216 KB Output is correct
9 Correct 10 ms 3832 KB Output is correct
10 Correct 9 ms 3788 KB Output is correct
11 Correct 8 ms 4028 KB Output is correct
12 Correct 13 ms 3944 KB Output is correct
13 Correct 8 ms 3992 KB Output is correct
14 Correct 19 ms 4168 KB Output is correct
15 Correct 24 ms 3904 KB Output is correct
16 Correct 26 ms 4044 KB Output is correct
17 Correct 30 ms 4344 KB Output is correct
18 Correct 26 ms 4220 KB Output is correct
19 Correct 24 ms 4040 KB Output is correct
20 Correct 28 ms 4012 KB Output is correct
21 Correct 41 ms 4408 KB Output is correct
22 Correct 60 ms 4264 KB Output is correct
23 Correct 61 ms 4132 KB Output is correct
24 Correct 53 ms 3948 KB Output is correct
25 Correct 62 ms 4436 KB Output is correct
26 Correct 61 ms 4336 KB Output is correct
27 Correct 62 ms 4200 KB Output is correct
28 Correct 65 ms 4120 KB Output is correct
29 Correct 86 ms 4040 KB Output is correct
30 Correct 110 ms 4228 KB Output is correct
31 Correct 119 ms 4128 KB Output is correct
32 Correct 106 ms 4536 KB Output is correct
33 Correct 123 ms 4092 KB Output is correct
34 Correct 107 ms 4784 KB Output is correct
35 Correct 111 ms 4152 KB Output is correct
36 Correct 108 ms 4004 KB Output is correct
37 Correct 147 ms 4216 KB Output is correct
38 Correct 200 ms 4504 KB Output is correct
39 Correct 198 ms 4924 KB Output is correct
40 Correct 201 ms 5088 KB Output is correct
41 Correct 209 ms 5420 KB Output is correct
42 Correct 194 ms 4768 KB Output is correct
43 Correct 192 ms 4628 KB Output is correct
44 Correct 196 ms 4868 KB Output is correct
45 Correct 249 ms 4608 KB Output is correct
46 Correct 307 ms 5476 KB Output is correct
47 Correct 303 ms 4580 KB Output is correct
48 Correct 306 ms 5016 KB Output is correct
49 Correct 312 ms 4984 KB Output is correct
50 Correct 319 ms 4660 KB Output is correct
51 Correct 314 ms 5072 KB Output is correct
52 Correct 310 ms 5220 KB Output is correct
53 Correct 308 ms 4728 KB Output is correct
54 Correct 311 ms 4520 KB Output is correct
55 Correct 314 ms 4412 KB Output is correct
56 Correct 312 ms 4980 KB Output is correct
57 Runtime error 52 ms 852 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -