Submission #725261

# Submission time Handle Problem Language Result Execution time Memory
725261 2023-04-17T05:42:28 Z SanguineChameleon Mars (APIO22_mars) C++17
21 / 100
81 ms 3204 KB
#include "mars.h"
#include <bits/stdc++.h>
using namespace std;

string process(vector<vector<string>> a, int i, int j, int k, int n) {
	if (k == n - 1) {
		int sz = n * 2 + 1;
		vector<vector<int>> grid(sz, vector<int>(sz, -1));
		vector<vector<bool>> flag(sz, vector<bool>(sz, false));
		const vector<int> dx = {1, -1, 0, 0};
		const vector<int> dy = {0, 0, 1, -1};
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				grid[i][j] = a[i][j][0] - '0';
			}
		}
		for (int x = 0; x < 3; x++) {
			for (int y = 0; y < 3; y++) {
				if ((x == 2 || y == 2) && (x != 0) && (y != 0)) {
					for (int i = 0; i < k * 2 + 1; i++) {
						grid[x + i][y + i] = a[x][y][i] - '0';
					}
				}
			}
		}
		for (int x = 0; x < 3; x++) {
			for (int y = 0; y < 3; y++) {
				if ((x == 2 || y == 2) && (x == 0 || y == 0)) {
					int pt = 0;
					int cx = x;
					int cy = y;
					for (int i = k * 2 + 1; i >= 1; i--) {
						for (int j = 0; j < i; j++) {
							grid[cx + j][cy + j] = a[x][y][pt++] - '0';
						}
						if (x == 0) {
							cy++;
						}
						if (y == 0) {
							cx++;
						}
					}
				}
			}
		}
		int cnt = 0;
		for (int i = 0; i < sz; i++) {
			for (int j = 0; j < sz; j++) {
				if (!flag[i][j] && grid[i][j]) {
					cnt++;
					flag[i][j] = true;
					deque<pair<int, int>> q = {{i, j}};
					while (!q.empty()) {
						int cx = q.front().first;
						int cy = q.front().second;
						q.pop_front();
						for (int d = 0; d < 4; d++) {
							int nx = cx + dx[d];
							int ny = cy + dy[d];
							if (0 <= nx && nx < sz && 0 <= ny && ny < sz && grid[nx][ny] && !flag[nx][ny]) {
								flag[nx][ny] = true;
								q.push_back({nx, ny});
							}
						}
					}
				}
			}
		}
		string res;
		while (cnt) {
			res += (char)('0' + (cnt & 1));
			cnt >>= 1;
		}
		res.resize(100, '0');
		return res;
	}
	string res = a[0][0].substr(0, 1);
	if (i == 2 * (n - k - 1) || j == 2 * (n - k - 1)) {
		res += a[1][1].substr(0, 1);
		res += a[2][2].substr(0, k * 2 + 1);
		if (j == 0) {
			res += a[1][0].substr(0, 1);
			res += a[2][1].substr(0, k * 2 + 1);
			res += a[2][0].substr(0, (k * 2 + 1) * (k * 2 + 2) / 2);
		}
		if (i == 0) {
			res += a[0][1].substr(0, 1);
			res += a[1][2].substr(0, k * 2 + 1);
			res += a[0][2].substr(0, (k * 2 + 1) * (k * 2 + 2) / 2);
		}
	}
	res.resize(100, '0');
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
14 Correct 38 ms 2976 KB Output is correct
15 Correct 53 ms 3000 KB Output is correct
16 Correct 53 ms 3068 KB Output is correct
17 Correct 49 ms 3052 KB Output is correct
18 Correct 53 ms 3132 KB Output is correct
19 Correct 48 ms 3024 KB Output is correct
20 Correct 51 ms 3204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
14 Correct 38 ms 2976 KB Output is correct
15 Correct 53 ms 3000 KB Output is correct
16 Correct 53 ms 3068 KB Output is correct
17 Correct 49 ms 3052 KB Output is correct
18 Correct 53 ms 3132 KB Output is correct
19 Correct 48 ms 3024 KB Output is correct
20 Correct 51 ms 3204 KB Output is correct
21 Correct 81 ms 3168 KB Output is correct
22 Incorrect 10 ms 336 KB Incorrect
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
14 Correct 38 ms 2976 KB Output is correct
15 Correct 53 ms 3000 KB Output is correct
16 Correct 53 ms 3068 KB Output is correct
17 Correct 49 ms 3052 KB Output is correct
18 Correct 53 ms 3132 KB Output is correct
19 Correct 48 ms 3024 KB Output is correct
20 Correct 51 ms 3204 KB Output is correct
21 Correct 81 ms 3168 KB Output is correct
22 Incorrect 10 ms 336 KB Incorrect
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
14 Correct 38 ms 2976 KB Output is correct
15 Correct 53 ms 3000 KB Output is correct
16 Correct 53 ms 3068 KB Output is correct
17 Correct 49 ms 3052 KB Output is correct
18 Correct 53 ms 3132 KB Output is correct
19 Correct 48 ms 3024 KB Output is correct
20 Correct 51 ms 3204 KB Output is correct
21 Correct 81 ms 3168 KB Output is correct
22 Incorrect 10 ms 336 KB Incorrect
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
14 Correct 38 ms 2976 KB Output is correct
15 Correct 53 ms 3000 KB Output is correct
16 Correct 53 ms 3068 KB Output is correct
17 Correct 49 ms 3052 KB Output is correct
18 Correct 53 ms 3132 KB Output is correct
19 Correct 48 ms 3024 KB Output is correct
20 Correct 51 ms 3204 KB Output is correct
21 Correct 81 ms 3168 KB Output is correct
22 Incorrect 10 ms 336 KB Incorrect
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
14 Correct 38 ms 2976 KB Output is correct
15 Correct 53 ms 3000 KB Output is correct
16 Correct 53 ms 3068 KB Output is correct
17 Correct 49 ms 3052 KB Output is correct
18 Correct 53 ms 3132 KB Output is correct
19 Correct 48 ms 3024 KB Output is correct
20 Correct 51 ms 3204 KB Output is correct
21 Correct 81 ms 3168 KB Output is correct
22 Incorrect 10 ms 336 KB Incorrect
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
14 Correct 38 ms 2976 KB Output is correct
15 Correct 53 ms 3000 KB Output is correct
16 Correct 53 ms 3068 KB Output is correct
17 Correct 49 ms 3052 KB Output is correct
18 Correct 53 ms 3132 KB Output is correct
19 Correct 48 ms 3024 KB Output is correct
20 Correct 51 ms 3204 KB Output is correct
21 Correct 81 ms 3168 KB Output is correct
22 Incorrect 10 ms 336 KB Incorrect
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2296 KB Output is correct
2 Correct 8 ms 2572 KB Output is correct
3 Correct 8 ms 2612 KB Output is correct
4 Correct 8 ms 2552 KB Output is correct
5 Correct 8 ms 2508 KB Output is correct
6 Correct 8 ms 2456 KB Output is correct
7 Correct 11 ms 2636 KB Output is correct
8 Correct 18 ms 2572 KB Output is correct
9 Correct 18 ms 2480 KB Output is correct
10 Correct 20 ms 2480 KB Output is correct
11 Correct 22 ms 2576 KB Output is correct
12 Correct 18 ms 2372 KB Output is correct
13 Correct 18 ms 2472 KB Output is correct
14 Correct 38 ms 2976 KB Output is correct
15 Correct 53 ms 3000 KB Output is correct
16 Correct 53 ms 3068 KB Output is correct
17 Correct 49 ms 3052 KB Output is correct
18 Correct 53 ms 3132 KB Output is correct
19 Correct 48 ms 3024 KB Output is correct
20 Correct 51 ms 3204 KB Output is correct
21 Correct 81 ms 3168 KB Output is correct
22 Incorrect 10 ms 336 KB Incorrect
23 Halted 0 ms 0 KB -