Submission #584559

# Submission time Handle Problem Language Result Execution time Memory
584559 2022-06-27T14:42:32 Z rainboy Mars (APIO22_mars) C++17
14 / 100
16 ms 2248 KB
#include "mars.h"
#include <string.h>

using namespace std;

typedef vector<string> vs;
typedef vector<vs> vvs;

const int N = 20, N_ = N * 2 + 1;

int find(int *ds, int i) {
	return ds[i] < 0 ? i : (ds[i] = find(ds, ds[i]));
}

void join(int *ds, int i, int j) {
	i = find(ds, i);
	j = find(ds, j);
	if (i == j)
		return;
	if (ds[i] > ds[j])
		ds[i] = j;
	else {
		if (ds[i] == ds[j])
			ds[i]--;
		ds[j] = i;
	}
}

string process(vvs ss, int i, int j, int k, int n) {
	string s(100, '0');
	int n_ = (k + 1) * 2 + 1;
	for (int i1 = 0; i1 < 3; i1++)
		for (int j1 = 0; j1 < 3; j1++)
			for (int i2 = 0; i2 < n_ - 2; i2++)
				for (int j2 = 0; j2 < n_ - 2; j2++)
					s[(i1 + i2) * n_ + (j1 + j2)] = ss[i1][j1][i2 * (n_ - 2) + j2];
	if (k < n - 1)
		return s;
	else {
		int ds[N_ * N_];
		memset(ds, -1, n_ * n_ * sizeof *ds);
		for (i = 0; i < n_; i++)
			for (j = 0; j < n_; j++)
				if (s[i * n_ + j] == '1') {
					if (i > 0 && s[(i - 1) * n_ + j] == '1')
						join(ds, i * n_ + j, (i - 1) * n_ + j);
					if (j > 0 && s[i * n_ + (j - 1)] == '1')
						join(ds, i * n_ + j, i * n_ + (j - 1));
				}
		int c = 0;
		for (i = 0; i < n_ * n_; i++)
			if (ds[i] < 0 && s[i] == '1')
				c++;
		string t(100, '0');
		for (int h = 0; h < 10; h++)
			t[h] = (c >> h & 1) + '0';
		return t;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
14 Runtime error 4 ms 436 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
14 Runtime error 4 ms 436 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
14 Runtime error 4 ms 436 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
14 Runtime error 4 ms 436 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
14 Runtime error 4 ms 436 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
14 Runtime error 4 ms 436 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
14 Runtime error 4 ms 436 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1824 KB Output is correct
2 Correct 6 ms 2124 KB Output is correct
3 Correct 5 ms 2020 KB Output is correct
4 Correct 8 ms 1888 KB Output is correct
5 Correct 8 ms 2248 KB Output is correct
6 Correct 8 ms 2136 KB Output is correct
7 Correct 8 ms 2040 KB Output is correct
8 Correct 16 ms 2036 KB Output is correct
9 Correct 16 ms 2076 KB Output is correct
10 Correct 15 ms 2236 KB Output is correct
11 Correct 16 ms 2036 KB Output is correct
12 Correct 16 ms 2188 KB Output is correct
13 Correct 16 ms 2032 KB Output is correct
14 Runtime error 4 ms 436 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -