Submission #1063837

# Submission time Handle Problem Language Result Execution time Memory
1063837 2024-08-18T04:11:02 Z kunzaZa183 Mars (APIO22_mars) C++17
54 / 100
394 ms 4680 KB
#include "mars.h"
#include <algorithm>
#include <bits/stdc++.h>
#include <utility>
using namespace std;

string process(vector<vector<string>> a, int x, int y, int k, int n) {

  auto helper = [&](int x, int y, int k) {
    vector<pair<int, int>> vpii;
    int dimens = n - k * 2;
    int each = n / dimens;
    int last = n % dimens;

    vector<int> vi(dimens, each);
    for (int i = 0; i < last; i++)
      vi[i]++;

    vector<int> coord(1, 0);
    for (int i = 0; i < vi.size() - 1; i++)
      coord.push_back(coord.back() + vi[i]);

    for (int i = coord[x]; i < coord[x] + vi[x]; i++)
      for (int j = coord[y]; j < coord[y] + vi[y]; j++)
        vpii.emplace_back(i, j);

    return vpii;
  };

  n *= 2;
  n++;

  vector<pair<int, int>> expect[3][3];

  map<pair<int, int>, int> mpiii;

  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) {
      expect[i][j] = helper(x + i, y + j, k);
      for (int k = 0; k < expect[i][j].size(); k++)
        mpiii[expect[i][j][k]] = a[i][j][k] - '0';
    }

  if (k == (n - 1) / 2 - 1) {
    vector<vector<int>> vvi(n, vector<int>(n));
    vector<vector<int>> compo(n, vector<int>(n, -1));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        vvi[i][j] = mpiii[make_pair(i, j)];
      }

    auto inr = [&](int x, int y) { return x >= 0 && x < n && y >= 0 && y < n; };

    const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
    function<void(int, int, int)> dfs = [&](int curx, int cury, int num) {
      compo[curx][cury] = num;
      for (int i = 0; i < 4; i++)
        if (inr(curx + dx[i], cury + dy[i])) {
          if (compo[curx + dx[i]][cury + dy[i]] == -1 &&
              vvi[curx + dx[i]][cury + dy[i]] == 1) {
            dfs(curx + dx[i], cury + dy[i], num);
          }
        }
    };

    // cout << "LAST\n";
    // for (auto a : vvi) {
    //   for (auto b : a)
    //     cout << b << " ";
    //   cout << "\n";
    // }

    int curval = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        if (compo[i][j] == -1 && vvi[i][j] == 1) {
          dfs(i, j, curval++);
        }
      }

    string s = bitset<100>(curval).to_string();
    reverse(s.begin(), s.end());
    return s;
  }

  vector<pair<int, int>> ans;

  ans = helper(x, y, k + 1);

  string s(100, '0');
  for (int i = 0; i < ans.size(); i++)
    s[i] = mpiii[ans[i]] + '0';

  return s;
}

Compilation message

mars.cpp: In lambda function:
mars.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for (int i = 0; i < vi.size() - 1; i++)
      |                     ~~^~~~~~~~~~~~~~~
mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:40:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |       for (int k = 0; k < expect[i][j].size(); k++)
      |                       ~~^~~~~~~~~~~~~~~~~~~~~
mars.cpp:91:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |   for (int i = 0; i < ans.size(); i++)
      |                   ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
14 Correct 22 ms 3196 KB Output is correct
15 Correct 32 ms 3700 KB Output is correct
16 Correct 33 ms 3244 KB Output is correct
17 Correct 34 ms 3740 KB Output is correct
18 Correct 32 ms 3228 KB Output is correct
19 Correct 34 ms 3404 KB Output is correct
20 Correct 32 ms 3336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
14 Correct 22 ms 3196 KB Output is correct
15 Correct 32 ms 3700 KB Output is correct
16 Correct 33 ms 3244 KB Output is correct
17 Correct 34 ms 3740 KB Output is correct
18 Correct 32 ms 3228 KB Output is correct
19 Correct 34 ms 3404 KB Output is correct
20 Correct 32 ms 3336 KB Output is correct
21 Correct 54 ms 3692 KB Output is correct
22 Correct 75 ms 3816 KB Output is correct
23 Correct 72 ms 3808 KB Output is correct
24 Correct 73 ms 3652 KB Output is correct
25 Correct 74 ms 3928 KB Output is correct
26 Correct 76 ms 3852 KB Output is correct
27 Correct 77 ms 3528 KB Output is correct
28 Correct 74 ms 3716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
14 Correct 22 ms 3196 KB Output is correct
15 Correct 32 ms 3700 KB Output is correct
16 Correct 33 ms 3244 KB Output is correct
17 Correct 34 ms 3740 KB Output is correct
18 Correct 32 ms 3228 KB Output is correct
19 Correct 34 ms 3404 KB Output is correct
20 Correct 32 ms 3336 KB Output is correct
21 Correct 54 ms 3692 KB Output is correct
22 Correct 75 ms 3816 KB Output is correct
23 Correct 72 ms 3808 KB Output is correct
24 Correct 73 ms 3652 KB Output is correct
25 Correct 74 ms 3928 KB Output is correct
26 Correct 76 ms 3852 KB Output is correct
27 Correct 77 ms 3528 KB Output is correct
28 Correct 74 ms 3716 KB Output is correct
29 Correct 100 ms 3804 KB Output is correct
30 Correct 139 ms 3864 KB Output is correct
31 Correct 130 ms 3984 KB Output is correct
32 Correct 135 ms 3872 KB Output is correct
33 Correct 136 ms 3872 KB Output is correct
34 Correct 138 ms 3872 KB Output is correct
35 Correct 134 ms 3824 KB Output is correct
36 Correct 145 ms 3980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
14 Correct 22 ms 3196 KB Output is correct
15 Correct 32 ms 3700 KB Output is correct
16 Correct 33 ms 3244 KB Output is correct
17 Correct 34 ms 3740 KB Output is correct
18 Correct 32 ms 3228 KB Output is correct
19 Correct 34 ms 3404 KB Output is correct
20 Correct 32 ms 3336 KB Output is correct
21 Correct 54 ms 3692 KB Output is correct
22 Correct 75 ms 3816 KB Output is correct
23 Correct 72 ms 3808 KB Output is correct
24 Correct 73 ms 3652 KB Output is correct
25 Correct 74 ms 3928 KB Output is correct
26 Correct 76 ms 3852 KB Output is correct
27 Correct 77 ms 3528 KB Output is correct
28 Correct 74 ms 3716 KB Output is correct
29 Correct 100 ms 3804 KB Output is correct
30 Correct 139 ms 3864 KB Output is correct
31 Correct 130 ms 3984 KB Output is correct
32 Correct 135 ms 3872 KB Output is correct
33 Correct 136 ms 3872 KB Output is correct
34 Correct 138 ms 3872 KB Output is correct
35 Correct 134 ms 3824 KB Output is correct
36 Correct 145 ms 3980 KB Output is correct
37 Correct 173 ms 4044 KB Output is correct
38 Correct 238 ms 4376 KB Output is correct
39 Correct 234 ms 4524 KB Output is correct
40 Correct 226 ms 4288 KB Output is correct
41 Correct 223 ms 4288 KB Output is correct
42 Correct 231 ms 4248 KB Output is correct
43 Correct 236 ms 4468 KB Output is correct
44 Correct 242 ms 4240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
14 Correct 22 ms 3196 KB Output is correct
15 Correct 32 ms 3700 KB Output is correct
16 Correct 33 ms 3244 KB Output is correct
17 Correct 34 ms 3740 KB Output is correct
18 Correct 32 ms 3228 KB Output is correct
19 Correct 34 ms 3404 KB Output is correct
20 Correct 32 ms 3336 KB Output is correct
21 Correct 54 ms 3692 KB Output is correct
22 Correct 75 ms 3816 KB Output is correct
23 Correct 72 ms 3808 KB Output is correct
24 Correct 73 ms 3652 KB Output is correct
25 Correct 74 ms 3928 KB Output is correct
26 Correct 76 ms 3852 KB Output is correct
27 Correct 77 ms 3528 KB Output is correct
28 Correct 74 ms 3716 KB Output is correct
29 Correct 100 ms 3804 KB Output is correct
30 Correct 139 ms 3864 KB Output is correct
31 Correct 130 ms 3984 KB Output is correct
32 Correct 135 ms 3872 KB Output is correct
33 Correct 136 ms 3872 KB Output is correct
34 Correct 138 ms 3872 KB Output is correct
35 Correct 134 ms 3824 KB Output is correct
36 Correct 145 ms 3980 KB Output is correct
37 Correct 173 ms 4044 KB Output is correct
38 Correct 238 ms 4376 KB Output is correct
39 Correct 234 ms 4524 KB Output is correct
40 Correct 226 ms 4288 KB Output is correct
41 Correct 223 ms 4288 KB Output is correct
42 Correct 231 ms 4248 KB Output is correct
43 Correct 236 ms 4468 KB Output is correct
44 Correct 242 ms 4240 KB Output is correct
45 Correct 310 ms 4416 KB Output is correct
46 Correct 382 ms 4492 KB Output is correct
47 Correct 394 ms 4472 KB Output is correct
48 Correct 376 ms 4472 KB Output is correct
49 Correct 379 ms 4456 KB Output is correct
50 Correct 362 ms 4460 KB Output is correct
51 Correct 377 ms 4680 KB Output is correct
52 Correct 376 ms 4620 KB Output is correct
53 Correct 355 ms 4424 KB Output is correct
54 Correct 380 ms 4444 KB Output is correct
55 Correct 388 ms 4620 KB Output is correct
56 Correct 390 ms 4492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
14 Correct 22 ms 3196 KB Output is correct
15 Correct 32 ms 3700 KB Output is correct
16 Correct 33 ms 3244 KB Output is correct
17 Correct 34 ms 3740 KB Output is correct
18 Correct 32 ms 3228 KB Output is correct
19 Correct 34 ms 3404 KB Output is correct
20 Correct 32 ms 3336 KB Output is correct
21 Correct 54 ms 3692 KB Output is correct
22 Correct 75 ms 3816 KB Output is correct
23 Correct 72 ms 3808 KB Output is correct
24 Correct 73 ms 3652 KB Output is correct
25 Correct 74 ms 3928 KB Output is correct
26 Correct 76 ms 3852 KB Output is correct
27 Correct 77 ms 3528 KB Output is correct
28 Correct 74 ms 3716 KB Output is correct
29 Correct 100 ms 3804 KB Output is correct
30 Correct 139 ms 3864 KB Output is correct
31 Correct 130 ms 3984 KB Output is correct
32 Correct 135 ms 3872 KB Output is correct
33 Correct 136 ms 3872 KB Output is correct
34 Correct 138 ms 3872 KB Output is correct
35 Correct 134 ms 3824 KB Output is correct
36 Correct 145 ms 3980 KB Output is correct
37 Correct 173 ms 4044 KB Output is correct
38 Correct 238 ms 4376 KB Output is correct
39 Correct 234 ms 4524 KB Output is correct
40 Correct 226 ms 4288 KB Output is correct
41 Correct 223 ms 4288 KB Output is correct
42 Correct 231 ms 4248 KB Output is correct
43 Correct 236 ms 4468 KB Output is correct
44 Correct 242 ms 4240 KB Output is correct
45 Correct 310 ms 4416 KB Output is correct
46 Correct 382 ms 4492 KB Output is correct
47 Correct 394 ms 4472 KB Output is correct
48 Correct 376 ms 4472 KB Output is correct
49 Correct 379 ms 4456 KB Output is correct
50 Correct 362 ms 4460 KB Output is correct
51 Correct 377 ms 4680 KB Output is correct
52 Correct 376 ms 4620 KB Output is correct
53 Correct 355 ms 4424 KB Output is correct
54 Correct 380 ms 4444 KB Output is correct
55 Correct 388 ms 4620 KB Output is correct
56 Correct 390 ms 4492 KB Output is correct
57 Runtime error 64 ms 848 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
14 Correct 22 ms 3196 KB Output is correct
15 Correct 32 ms 3700 KB Output is correct
16 Correct 33 ms 3244 KB Output is correct
17 Correct 34 ms 3740 KB Output is correct
18 Correct 32 ms 3228 KB Output is correct
19 Correct 34 ms 3404 KB Output is correct
20 Correct 32 ms 3336 KB Output is correct
21 Correct 54 ms 3692 KB Output is correct
22 Correct 75 ms 3816 KB Output is correct
23 Correct 72 ms 3808 KB Output is correct
24 Correct 73 ms 3652 KB Output is correct
25 Correct 74 ms 3928 KB Output is correct
26 Correct 76 ms 3852 KB Output is correct
27 Correct 77 ms 3528 KB Output is correct
28 Correct 74 ms 3716 KB Output is correct
29 Correct 100 ms 3804 KB Output is correct
30 Correct 139 ms 3864 KB Output is correct
31 Correct 130 ms 3984 KB Output is correct
32 Correct 135 ms 3872 KB Output is correct
33 Correct 136 ms 3872 KB Output is correct
34 Correct 138 ms 3872 KB Output is correct
35 Correct 134 ms 3824 KB Output is correct
36 Correct 145 ms 3980 KB Output is correct
37 Correct 173 ms 4044 KB Output is correct
38 Correct 238 ms 4376 KB Output is correct
39 Correct 234 ms 4524 KB Output is correct
40 Correct 226 ms 4288 KB Output is correct
41 Correct 223 ms 4288 KB Output is correct
42 Correct 231 ms 4248 KB Output is correct
43 Correct 236 ms 4468 KB Output is correct
44 Correct 242 ms 4240 KB Output is correct
45 Correct 310 ms 4416 KB Output is correct
46 Correct 382 ms 4492 KB Output is correct
47 Correct 394 ms 4472 KB Output is correct
48 Correct 376 ms 4472 KB Output is correct
49 Correct 379 ms 4456 KB Output is correct
50 Correct 362 ms 4460 KB Output is correct
51 Correct 377 ms 4680 KB Output is correct
52 Correct 376 ms 4620 KB Output is correct
53 Correct 355 ms 4424 KB Output is correct
54 Correct 380 ms 4444 KB Output is correct
55 Correct 388 ms 4620 KB Output is correct
56 Correct 390 ms 4492 KB Output is correct
57 Runtime error 64 ms 848 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3372 KB Output is correct
2 Correct 6 ms 3072 KB Output is correct
3 Correct 8 ms 2660 KB Output is correct
4 Correct 5 ms 2852 KB Output is correct
5 Correct 7 ms 2792 KB Output is correct
6 Correct 8 ms 2744 KB Output is correct
7 Correct 10 ms 2908 KB Output is correct
8 Correct 11 ms 3184 KB Output is correct
9 Correct 14 ms 3164 KB Output is correct
10 Correct 12 ms 2756 KB Output is correct
11 Correct 15 ms 3444 KB Output is correct
12 Correct 15 ms 2964 KB Output is correct
13 Correct 13 ms 3128 KB Output is correct
14 Correct 22 ms 3196 KB Output is correct
15 Correct 32 ms 3700 KB Output is correct
16 Correct 33 ms 3244 KB Output is correct
17 Correct 34 ms 3740 KB Output is correct
18 Correct 32 ms 3228 KB Output is correct
19 Correct 34 ms 3404 KB Output is correct
20 Correct 32 ms 3336 KB Output is correct
21 Correct 54 ms 3692 KB Output is correct
22 Correct 75 ms 3816 KB Output is correct
23 Correct 72 ms 3808 KB Output is correct
24 Correct 73 ms 3652 KB Output is correct
25 Correct 74 ms 3928 KB Output is correct
26 Correct 76 ms 3852 KB Output is correct
27 Correct 77 ms 3528 KB Output is correct
28 Correct 74 ms 3716 KB Output is correct
29 Correct 100 ms 3804 KB Output is correct
30 Correct 139 ms 3864 KB Output is correct
31 Correct 130 ms 3984 KB Output is correct
32 Correct 135 ms 3872 KB Output is correct
33 Correct 136 ms 3872 KB Output is correct
34 Correct 138 ms 3872 KB Output is correct
35 Correct 134 ms 3824 KB Output is correct
36 Correct 145 ms 3980 KB Output is correct
37 Correct 173 ms 4044 KB Output is correct
38 Correct 238 ms 4376 KB Output is correct
39 Correct 234 ms 4524 KB Output is correct
40 Correct 226 ms 4288 KB Output is correct
41 Correct 223 ms 4288 KB Output is correct
42 Correct 231 ms 4248 KB Output is correct
43 Correct 236 ms 4468 KB Output is correct
44 Correct 242 ms 4240 KB Output is correct
45 Correct 310 ms 4416 KB Output is correct
46 Correct 382 ms 4492 KB Output is correct
47 Correct 394 ms 4472 KB Output is correct
48 Correct 376 ms 4472 KB Output is correct
49 Correct 379 ms 4456 KB Output is correct
50 Correct 362 ms 4460 KB Output is correct
51 Correct 377 ms 4680 KB Output is correct
52 Correct 376 ms 4620 KB Output is correct
53 Correct 355 ms 4424 KB Output is correct
54 Correct 380 ms 4444 KB Output is correct
55 Correct 388 ms 4620 KB Output is correct
56 Correct 390 ms 4492 KB Output is correct
57 Runtime error 64 ms 848 KB Execution killed with signal 6
58 Halted 0 ms 0 KB -