답안 #1103590

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

#define SIZE 100

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');
}

string cc(const vector<vector<string>> &a, int n) {
	string grid = collect(a, n - 1);
	int m = 2 * n + 1;
	auto get = [&](int i, int j) { return grid[m * i + j] == '1'; };
	
	vector<vector<bool>> vis(m, vector<bool>(m));

	int cnt = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			if (vis[i][j] || !get(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] || !get(x, y)) continue;
				vis[x][y] = true;

				if (x > 0)
					q.emplace(x - 1, y);
				if (x < m - 1)
					q.emplace(x + 1, y);
				if (y > 0)
					q.emplace(x, y - 1);
				if (y < m - 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);
	
	assert(false);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
14 Runtime error 4 ms 464 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
14 Runtime error 4 ms 464 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
14 Runtime error 4 ms 464 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
14 Runtime error 4 ms 464 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
14 Runtime error 4 ms 464 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
14 Runtime error 4 ms 464 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
14 Runtime error 4 ms 464 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2728 KB Output is correct
2 Correct 8 ms 3004 KB Output is correct
3 Correct 8 ms 3080 KB Output is correct
4 Correct 8 ms 2916 KB Output is correct
5 Correct 8 ms 2836 KB Output is correct
6 Correct 8 ms 2724 KB Output is correct
7 Correct 9 ms 3080 KB Output is correct
8 Correct 16 ms 2740 KB Output is correct
9 Correct 15 ms 2888 KB Output is correct
10 Correct 15 ms 3264 KB Output is correct
11 Correct 16 ms 2980 KB Output is correct
12 Correct 16 ms 2724 KB Output is correct
13 Correct 13 ms 2832 KB Output is correct
14 Runtime error 4 ms 464 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -