답안 #1103773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103773 2024-10-21T16:24:11 Z fve5 화성 (APIO22_mars) C++17
44 / 100
348 ms 4900 KB
#include <bits/stdc++.h>
#include "mars.h"
using namespace std;

#define SIZE 100
#define MAXL 45

string collect(const vector<vector<string>> &a, int k) {
	string ans;
	for (int i = 0; i < 2 * k + 3; i++) {
		if (i < 2 * k + 1) {
			ans += a[0][0].substr(i * (2 * k + 1), 2 * k + 1) + a[0][1][i * (2 * k + 1) + 2 * k] + a[0][2][i * (2 * k + 1) + 2 * k];
		} else {
			int j = i - 2 * k;
			ans += a[j][0].substr((2 * k) * (2 * k + 1), 2 * k + 1) + a[j][1][(2 * k) * (2 * k + 1) + 2 * k] + a[j][2][(2 * k) * (2 * k + 1) + 2 * k];
		}
	}
	
	return ans + string(SIZE - ans.size(), '0');
}

vector<vector<map<int, int>>> get_trans(int n) {
	vector<vector<map<int, int>>> trans(2 * n + 1, vector<map<int, int>>(2 * n + 1));
	int sz = 2 * n + 1;

	for (int x = 0; ; x++) {
		int sx = max(0, sz - 9 * (x + 1));
		int tx = sx == 0 ? 0 : 2 - x;

		for (int y = 0; ; y++) {
			int sy = max(0, sz - 9 * (y + 1));
			int ty = sy == 0 ? 0 : 2 - y;

			int cnt = 0, cx = sx, cy = sy;
			while (cx != tx || cy != ty) {
				int nx = cx - 2 * (cx != tx);
				int ny = cy - 2 * (cy != ty);

				trans[nx][ny][cnt] = ((cx != tx) << 1) | (cy != ty);

				cx = nx;
				cy = ny;
				cnt++;
			}

			if (sy == 0) break;
		}
		if (sx == 0) break;
	}

	return trans;
}

int last_call(int n, int i, int j) { return min((2 * n - i) / 2, (2 * n - j) / 2) - 1; }

string transfer(const vector<vector<string>> &a, int i, int j, int k, int n) {
	switch (get_trans(n)[i][j][k - 4]) {
		case 0: return a[0][0];
		case 1: return a[0][2];
		case 2: return a[2][0];
		case 3: return a[2][2];
	}
}

string cc(const vector<vector<string>> &a, int n) {
	int sz = 2 * n + 1;
	vector<vector<bool>> grid(sz, vector<bool>(sz));

	if (n > 4) {
		for (int x = 0; ; x++) {
			int sx = max(0, sz - 9 * (x + 1));
			int tx = sx == 0 ? 0 : 2 - x;

			for (int y = 0; ; y++) {
				int sy = max(0, sz - 9 * (y + 1));
				int ty = sy == 0 ? 0 : 2 - y;

				int w = sy == 0 ? (sz - 1) % 9 + 1 : 9;
				int h = sx == 0 ? (sz - 1) % 9 + 1 : 9;

				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						grid[sx + i][sy + j] = a[tx][ty][i * 9 + j] == '1';
					}
				}

				if (sy == 0) break;
			}
			if (sx == 0) break;
		}
	} else {
		string g = collect(a, n - 1);
		for (int i = 0; i < sz; i++)
			for (int j = 0; j < sz; j++)
				grid[i][j] = g[sz * i + j] == '1';
	}

	vector<vector<bool>> vis(sz, vector<bool>(sz));

	int cnt = 0;
	for (int i = 0; i < sz; i++) {
		for (int j = 0; j < sz; j++) {
			if (vis[i][j] || !grid[i][j]) continue;

			cnt++;
			queue<pair<int, int>> q;
			q.emplace(i, j);

			while (!q.empty()) {
				auto [x, y] = q.front(); q.pop();
				if (vis[x][y] || !grid[x][y]) continue;
				vis[x][y] = true;

				if (x > 0)
					q.emplace(x - 1, y);
				if (x < sz - 1)
					q.emplace(x + 1, y);
				if (y > 0)
					q.emplace(x, y - 1);
				if (y < sz - 1)
					q.emplace(x, y + 1);
			}
		}
	}

	string ans(SIZE, '0');
	for (int i = 0; i < SIZE; i++) {
		if (cnt & 1)
			ans[i] = '1';
		cnt >>= 1;
	}
	return ans;
}

string process(vector<vector<string>> a, int i, int j, int k, int n) {
	if (k == n - 1)
		return cc(a, n);
	if (k <= 3)
		return collect(a, k);

	return transfer(a, i, j, k, n);
	
	assert(false);
}

Compilation message

mars.cpp: In function 'std::string transfer(const std::vector<std::vector<std::__cxx11::basic_string<char> > >&, int, int, int, int)':
mars.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
14 Correct 26 ms 3136 KB Output is correct
15 Correct 33 ms 3756 KB Output is correct
16 Correct 32 ms 3664 KB Output is correct
17 Correct 29 ms 3248 KB Output is correct
18 Correct 32 ms 3676 KB Output is correct
19 Correct 30 ms 3788 KB Output is correct
20 Correct 28 ms 3528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
14 Correct 26 ms 3136 KB Output is correct
15 Correct 33 ms 3756 KB Output is correct
16 Correct 32 ms 3664 KB Output is correct
17 Correct 29 ms 3248 KB Output is correct
18 Correct 32 ms 3676 KB Output is correct
19 Correct 30 ms 3788 KB Output is correct
20 Correct 28 ms 3528 KB Output is correct
21 Correct 43 ms 3864 KB Output is correct
22 Correct 65 ms 3992 KB Output is correct
23 Correct 68 ms 4472 KB Output is correct
24 Correct 71 ms 4208 KB Output is correct
25 Correct 68 ms 4264 KB Output is correct
26 Correct 67 ms 4044 KB Output is correct
27 Correct 73 ms 4244 KB Output is correct
28 Correct 77 ms 4232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
14 Correct 26 ms 3136 KB Output is correct
15 Correct 33 ms 3756 KB Output is correct
16 Correct 32 ms 3664 KB Output is correct
17 Correct 29 ms 3248 KB Output is correct
18 Correct 32 ms 3676 KB Output is correct
19 Correct 30 ms 3788 KB Output is correct
20 Correct 28 ms 3528 KB Output is correct
21 Correct 43 ms 3864 KB Output is correct
22 Correct 65 ms 3992 KB Output is correct
23 Correct 68 ms 4472 KB Output is correct
24 Correct 71 ms 4208 KB Output is correct
25 Correct 68 ms 4264 KB Output is correct
26 Correct 67 ms 4044 KB Output is correct
27 Correct 73 ms 4244 KB Output is correct
28 Correct 77 ms 4232 KB Output is correct
29 Correct 105 ms 4340 KB Output is correct
30 Correct 136 ms 4248 KB Output is correct
31 Correct 156 ms 4508 KB Output is correct
32 Correct 130 ms 4548 KB Output is correct
33 Correct 130 ms 4260 KB Output is correct
34 Correct 132 ms 4256 KB Output is correct
35 Correct 133 ms 4276 KB Output is correct
36 Correct 130 ms 4300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
14 Correct 26 ms 3136 KB Output is correct
15 Correct 33 ms 3756 KB Output is correct
16 Correct 32 ms 3664 KB Output is correct
17 Correct 29 ms 3248 KB Output is correct
18 Correct 32 ms 3676 KB Output is correct
19 Correct 30 ms 3788 KB Output is correct
20 Correct 28 ms 3528 KB Output is correct
21 Correct 43 ms 3864 KB Output is correct
22 Correct 65 ms 3992 KB Output is correct
23 Correct 68 ms 4472 KB Output is correct
24 Correct 71 ms 4208 KB Output is correct
25 Correct 68 ms 4264 KB Output is correct
26 Correct 67 ms 4044 KB Output is correct
27 Correct 73 ms 4244 KB Output is correct
28 Correct 77 ms 4232 KB Output is correct
29 Correct 105 ms 4340 KB Output is correct
30 Correct 136 ms 4248 KB Output is correct
31 Correct 156 ms 4508 KB Output is correct
32 Correct 130 ms 4548 KB Output is correct
33 Correct 130 ms 4260 KB Output is correct
34 Correct 132 ms 4256 KB Output is correct
35 Correct 133 ms 4276 KB Output is correct
36 Correct 130 ms 4300 KB Output is correct
37 Correct 201 ms 4520 KB Output is correct
38 Correct 260 ms 4628 KB Output is correct
39 Correct 255 ms 4672 KB Output is correct
40 Correct 255 ms 4636 KB Output is correct
41 Correct 267 ms 4696 KB Output is correct
42 Correct 275 ms 4688 KB Output is correct
43 Correct 263 ms 4656 KB Output is correct
44 Correct 253 ms 4708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
14 Correct 26 ms 3136 KB Output is correct
15 Correct 33 ms 3756 KB Output is correct
16 Correct 32 ms 3664 KB Output is correct
17 Correct 29 ms 3248 KB Output is correct
18 Correct 32 ms 3676 KB Output is correct
19 Correct 30 ms 3788 KB Output is correct
20 Correct 28 ms 3528 KB Output is correct
21 Correct 43 ms 3864 KB Output is correct
22 Correct 65 ms 3992 KB Output is correct
23 Correct 68 ms 4472 KB Output is correct
24 Correct 71 ms 4208 KB Output is correct
25 Correct 68 ms 4264 KB Output is correct
26 Correct 67 ms 4044 KB Output is correct
27 Correct 73 ms 4244 KB Output is correct
28 Correct 77 ms 4232 KB Output is correct
29 Correct 105 ms 4340 KB Output is correct
30 Correct 136 ms 4248 KB Output is correct
31 Correct 156 ms 4508 KB Output is correct
32 Correct 130 ms 4548 KB Output is correct
33 Correct 130 ms 4260 KB Output is correct
34 Correct 132 ms 4256 KB Output is correct
35 Correct 133 ms 4276 KB Output is correct
36 Correct 130 ms 4300 KB Output is correct
37 Correct 201 ms 4520 KB Output is correct
38 Correct 260 ms 4628 KB Output is correct
39 Correct 255 ms 4672 KB Output is correct
40 Correct 255 ms 4636 KB Output is correct
41 Correct 267 ms 4696 KB Output is correct
42 Correct 275 ms 4688 KB Output is correct
43 Correct 263 ms 4656 KB Output is correct
44 Correct 253 ms 4708 KB Output is correct
45 Correct 348 ms 4900 KB Output is correct
46 Incorrect 52 ms 632 KB Incorrect
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
14 Correct 26 ms 3136 KB Output is correct
15 Correct 33 ms 3756 KB Output is correct
16 Correct 32 ms 3664 KB Output is correct
17 Correct 29 ms 3248 KB Output is correct
18 Correct 32 ms 3676 KB Output is correct
19 Correct 30 ms 3788 KB Output is correct
20 Correct 28 ms 3528 KB Output is correct
21 Correct 43 ms 3864 KB Output is correct
22 Correct 65 ms 3992 KB Output is correct
23 Correct 68 ms 4472 KB Output is correct
24 Correct 71 ms 4208 KB Output is correct
25 Correct 68 ms 4264 KB Output is correct
26 Correct 67 ms 4044 KB Output is correct
27 Correct 73 ms 4244 KB Output is correct
28 Correct 77 ms 4232 KB Output is correct
29 Correct 105 ms 4340 KB Output is correct
30 Correct 136 ms 4248 KB Output is correct
31 Correct 156 ms 4508 KB Output is correct
32 Correct 130 ms 4548 KB Output is correct
33 Correct 130 ms 4260 KB Output is correct
34 Correct 132 ms 4256 KB Output is correct
35 Correct 133 ms 4276 KB Output is correct
36 Correct 130 ms 4300 KB Output is correct
37 Correct 201 ms 4520 KB Output is correct
38 Correct 260 ms 4628 KB Output is correct
39 Correct 255 ms 4672 KB Output is correct
40 Correct 255 ms 4636 KB Output is correct
41 Correct 267 ms 4696 KB Output is correct
42 Correct 275 ms 4688 KB Output is correct
43 Correct 263 ms 4656 KB Output is correct
44 Correct 253 ms 4708 KB Output is correct
45 Correct 348 ms 4900 KB Output is correct
46 Incorrect 52 ms 632 KB Incorrect
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
14 Correct 26 ms 3136 KB Output is correct
15 Correct 33 ms 3756 KB Output is correct
16 Correct 32 ms 3664 KB Output is correct
17 Correct 29 ms 3248 KB Output is correct
18 Correct 32 ms 3676 KB Output is correct
19 Correct 30 ms 3788 KB Output is correct
20 Correct 28 ms 3528 KB Output is correct
21 Correct 43 ms 3864 KB Output is correct
22 Correct 65 ms 3992 KB Output is correct
23 Correct 68 ms 4472 KB Output is correct
24 Correct 71 ms 4208 KB Output is correct
25 Correct 68 ms 4264 KB Output is correct
26 Correct 67 ms 4044 KB Output is correct
27 Correct 73 ms 4244 KB Output is correct
28 Correct 77 ms 4232 KB Output is correct
29 Correct 105 ms 4340 KB Output is correct
30 Correct 136 ms 4248 KB Output is correct
31 Correct 156 ms 4508 KB Output is correct
32 Correct 130 ms 4548 KB Output is correct
33 Correct 130 ms 4260 KB Output is correct
34 Correct 132 ms 4256 KB Output is correct
35 Correct 133 ms 4276 KB Output is correct
36 Correct 130 ms 4300 KB Output is correct
37 Correct 201 ms 4520 KB Output is correct
38 Correct 260 ms 4628 KB Output is correct
39 Correct 255 ms 4672 KB Output is correct
40 Correct 255 ms 4636 KB Output is correct
41 Correct 267 ms 4696 KB Output is correct
42 Correct 275 ms 4688 KB Output is correct
43 Correct 263 ms 4656 KB Output is correct
44 Correct 253 ms 4708 KB Output is correct
45 Correct 348 ms 4900 KB Output is correct
46 Incorrect 52 ms 632 KB Incorrect
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2732 KB Output is correct
2 Correct 8 ms 2824 KB Output is correct
3 Correct 8 ms 2924 KB Output is correct
4 Correct 8 ms 3352 KB Output is correct
5 Correct 8 ms 2824 KB Output is correct
6 Correct 8 ms 2936 KB Output is correct
7 Correct 10 ms 3248 KB Output is correct
8 Correct 16 ms 3252 KB Output is correct
9 Correct 16 ms 3204 KB Output is correct
10 Correct 17 ms 3020 KB Output is correct
11 Correct 13 ms 3092 KB Output is correct
12 Correct 16 ms 3036 KB Output is correct
13 Correct 14 ms 2724 KB Output is correct
14 Correct 26 ms 3136 KB Output is correct
15 Correct 33 ms 3756 KB Output is correct
16 Correct 32 ms 3664 KB Output is correct
17 Correct 29 ms 3248 KB Output is correct
18 Correct 32 ms 3676 KB Output is correct
19 Correct 30 ms 3788 KB Output is correct
20 Correct 28 ms 3528 KB Output is correct
21 Correct 43 ms 3864 KB Output is correct
22 Correct 65 ms 3992 KB Output is correct
23 Correct 68 ms 4472 KB Output is correct
24 Correct 71 ms 4208 KB Output is correct
25 Correct 68 ms 4264 KB Output is correct
26 Correct 67 ms 4044 KB Output is correct
27 Correct 73 ms 4244 KB Output is correct
28 Correct 77 ms 4232 KB Output is correct
29 Correct 105 ms 4340 KB Output is correct
30 Correct 136 ms 4248 KB Output is correct
31 Correct 156 ms 4508 KB Output is correct
32 Correct 130 ms 4548 KB Output is correct
33 Correct 130 ms 4260 KB Output is correct
34 Correct 132 ms 4256 KB Output is correct
35 Correct 133 ms 4276 KB Output is correct
36 Correct 130 ms 4300 KB Output is correct
37 Correct 201 ms 4520 KB Output is correct
38 Correct 260 ms 4628 KB Output is correct
39 Correct 255 ms 4672 KB Output is correct
40 Correct 255 ms 4636 KB Output is correct
41 Correct 267 ms 4696 KB Output is correct
42 Correct 275 ms 4688 KB Output is correct
43 Correct 263 ms 4656 KB Output is correct
44 Correct 253 ms 4708 KB Output is correct
45 Correct 348 ms 4900 KB Output is correct
46 Incorrect 52 ms 632 KB Incorrect
47 Halted 0 ms 0 KB -