Submission #1103585

# Submission time Handle Problem Language Result Execution time Memory
1103585 2024-10-21T11:02:57 Z fve5 Mars (APIO22_mars) C++17
6 / 100
15 ms 3232 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 = a[0][0].substr(0, 2 * k + 1) + a[0][1][2 * k] + a[0][2][2 * k]
			   + a[1][0].substr(0, 2 * k + 1) + a[1][1][2 * k] + a[1][2][2 * k]
			   + a[2][0].substr(0, 2 * k + 1) + a[2][1][2 * k] + a[2][2][2 * k]
			   + a[2][0].substr(2 * k + 1, 2 * k + 1) + a[2][1][4 * k + 1] + a[2][2][4 * k + 1]
			   + a[2][0].substr(4 * k + 2, 2 * k + 1) + a[2][1][6 * k + 2] + a[2][2][6 * k + 2];
	
	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);
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3052 KB Output is correct
2 Correct 8 ms 2840 KB Output is correct
3 Correct 8 ms 3092 KB Output is correct
4 Correct 15 ms 2832 KB Output is correct
5 Correct 8 ms 2732 KB Output is correct
6 Correct 8 ms 3232 KB Output is correct
7 Incorrect 1 ms 328 KB Incorrect
8 Halted 0 ms 0 KB -