Submission #1063966

# Submission time Handle Problem Language Result Execution time Memory
1063966 2024-08-18T06:54:47 Z thinknoexit Mars (APIO22_mars) C++17
14 / 100
11 ms 3020 KB
#include "mars.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int di[4] = { 1, 0, -1, 0 }, dj[4] = { 0, 1, 0, -1 };
// n <= 2
string count_island(int n, vector<string> v) {
	vector<vector<bool>> vis(n, vector<bool>(n, false));
	function<void(int, int)> dfs;
	dfs = [&](int i, int j) {
		vis[i][j] = 1;
		for (int k = 0;k < 4;k++) {
			int ii = i + di[k], jj = j + dj[k];
			if (ii < 0 || jj < 0 || ii >= n || jj >= n) continue;
			if (vis[ii][jj] || v[ii][jj] == '0') continue;
			dfs(ii, jj);
		}
		};
	int cnt = 0;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			if (!vis[i][j] && v[i][j] == '1') {
				cnt++;
				dfs(i, j);
			}
		}
	}
	string s = string(100, '0');
	for (int j = 0;j < 10;j++) {
		s[j] = ((cnt >> j) & 1) + '0';
	}
	return s;
}
string process(vector<vector<string>> a, int i, int j, int k, int n) {
	if (n == 1) {
		vector<string> v(3, string(3, '0'));
		for (int i = 0;i < 3;i++) {
			for (int j = 0;j < 3;j++) {
				v[i][j] = a[i][j][0];
			}
		}
		return count_island(2 * n + 1, v);
	}
	if (k == 0) {
		string s = string(100, '0');
		for (int i = 0;i < 3;i++) {
			for (int j = 0;j < 3;j++) {
				s[i * 3 + j] = a[i][j][0];
			}
		}
		return s;
	}
	vector<string> v(2 * k + 3, string(2 * k + 3, '0'));
	// a[0][0], a[0][2], a[2][0], a[2][2]
	for (int i = 0;i < 2 * k + 1;i++) {
		for (int j = 0;j < 2 * k + 1;j++) {
			v[i][j] = a[0][0][i * (2 * k + 1) + j];
			v[2 + i][j] = a[2][0][i * (2 * k + 1) + j];
			v[i][2 + j] = a[0][2][i * (2 * k + 1) + j];
			v[2 + i][2 + j] = a[2][2][i * (2 * k + 1) + j];
		}
	}
	if (k == n - 1) return count_island(2 * n + 1, v);
	string s = string(100, '0');
	for (int i = 0;i < 2 * k + 3;i++) for (int j = 0;j < 2 * k + 3;j++) {
		s[i * (2 * k + 3) + j] = v[i][j];
	}
	return s;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
14 Runtime error 3 ms 444 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
14 Runtime error 3 ms 444 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
14 Runtime error 3 ms 444 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
14 Runtime error 3 ms 444 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
14 Runtime error 3 ms 444 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
14 Runtime error 3 ms 444 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
14 Runtime error 3 ms 444 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3016 KB Output is correct
2 Correct 8 ms 2808 KB Output is correct
3 Correct 7 ms 2828 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 7 ms 2876 KB Output is correct
6 Correct 8 ms 2836 KB Output is correct
7 Correct 8 ms 3020 KB Output is correct
8 Correct 10 ms 2944 KB Output is correct
9 Correct 8 ms 2672 KB Output is correct
10 Correct 11 ms 2836 KB Output is correct
11 Correct 11 ms 2740 KB Output is correct
12 Correct 9 ms 3012 KB Output is correct
13 Correct 8 ms 2784 KB Output is correct
14 Runtime error 3 ms 444 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -