Submission #584588

# Submission time Handle Problem Language Result Execution time Memory
584588 2022-06-27T15:13:27 Z rainboy Mars (APIO22_mars) C++17
44 / 100
395 ms 3336 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) {
	int n_ = (k + 1) * 2 + 1, m = (n + 1) / 3;
	if (k < m) {
		string s(100, '0');
		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];
		return s;
	} else if (k < n - 1) {
		for (int i1 = 0; i1 < 3; i1++)
			for (int j1 = 0; j1 < 3; j1++)
				if (i == i1 * (n - 1 - k) && j == j1 * (n - 1 - k))
					return ss[i1][j1];
		return ss[0][0];
	} else {
		string s(n_ * n_, '0');
		int m_ = m * 2 + 1;
		for (int i1 = 0; i1 < 3; i1++)
			for (int j1 = 0; j1 < 3; j1++)
				for (int i2 = 0; i2 < m_; i2++)
					for (int j2 = 0; j2 < m_; j2++)
						s[(i1 * (n - m) + i2) * n_ + (j1 * (n - m) + j2)] = ss[i1][j1][i2 * m_ + j2];
		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 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
14 Correct 32 ms 2460 KB Output is correct
15 Correct 41 ms 2532 KB Output is correct
16 Correct 40 ms 2680 KB Output is correct
17 Correct 40 ms 2520 KB Output is correct
18 Correct 43 ms 2508 KB Output is correct
19 Correct 40 ms 2632 KB Output is correct
20 Correct 37 ms 2568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
14 Correct 32 ms 2460 KB Output is correct
15 Correct 41 ms 2532 KB Output is correct
16 Correct 40 ms 2680 KB Output is correct
17 Correct 40 ms 2520 KB Output is correct
18 Correct 43 ms 2508 KB Output is correct
19 Correct 40 ms 2632 KB Output is correct
20 Correct 37 ms 2568 KB Output is correct
21 Correct 61 ms 2572 KB Output is correct
22 Correct 84 ms 2704 KB Output is correct
23 Correct 86 ms 2840 KB Output is correct
24 Correct 96 ms 2696 KB Output is correct
25 Correct 87 ms 2852 KB Output is correct
26 Correct 97 ms 2772 KB Output is correct
27 Correct 93 ms 2760 KB Output is correct
28 Correct 87 ms 2748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
14 Correct 32 ms 2460 KB Output is correct
15 Correct 41 ms 2532 KB Output is correct
16 Correct 40 ms 2680 KB Output is correct
17 Correct 40 ms 2520 KB Output is correct
18 Correct 43 ms 2508 KB Output is correct
19 Correct 40 ms 2632 KB Output is correct
20 Correct 37 ms 2568 KB Output is correct
21 Correct 61 ms 2572 KB Output is correct
22 Correct 84 ms 2704 KB Output is correct
23 Correct 86 ms 2840 KB Output is correct
24 Correct 96 ms 2696 KB Output is correct
25 Correct 87 ms 2852 KB Output is correct
26 Correct 97 ms 2772 KB Output is correct
27 Correct 93 ms 2760 KB Output is correct
28 Correct 87 ms 2748 KB Output is correct
29 Correct 130 ms 2744 KB Output is correct
30 Correct 168 ms 2844 KB Output is correct
31 Correct 162 ms 3008 KB Output is correct
32 Correct 167 ms 2832 KB Output is correct
33 Correct 182 ms 2848 KB Output is correct
34 Correct 176 ms 2828 KB Output is correct
35 Correct 178 ms 2864 KB Output is correct
36 Correct 175 ms 2840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
14 Correct 32 ms 2460 KB Output is correct
15 Correct 41 ms 2532 KB Output is correct
16 Correct 40 ms 2680 KB Output is correct
17 Correct 40 ms 2520 KB Output is correct
18 Correct 43 ms 2508 KB Output is correct
19 Correct 40 ms 2632 KB Output is correct
20 Correct 37 ms 2568 KB Output is correct
21 Correct 61 ms 2572 KB Output is correct
22 Correct 84 ms 2704 KB Output is correct
23 Correct 86 ms 2840 KB Output is correct
24 Correct 96 ms 2696 KB Output is correct
25 Correct 87 ms 2852 KB Output is correct
26 Correct 97 ms 2772 KB Output is correct
27 Correct 93 ms 2760 KB Output is correct
28 Correct 87 ms 2748 KB Output is correct
29 Correct 130 ms 2744 KB Output is correct
30 Correct 168 ms 2844 KB Output is correct
31 Correct 162 ms 3008 KB Output is correct
32 Correct 167 ms 2832 KB Output is correct
33 Correct 182 ms 2848 KB Output is correct
34 Correct 176 ms 2828 KB Output is correct
35 Correct 178 ms 2864 KB Output is correct
36 Correct 175 ms 2840 KB Output is correct
37 Correct 236 ms 3208 KB Output is correct
38 Correct 292 ms 3336 KB Output is correct
39 Correct 288 ms 3240 KB Output is correct
40 Correct 303 ms 3324 KB Output is correct
41 Correct 302 ms 3336 KB Output is correct
42 Correct 305 ms 3264 KB Output is correct
43 Correct 315 ms 3184 KB Output is correct
44 Correct 298 ms 3176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
14 Correct 32 ms 2460 KB Output is correct
15 Correct 41 ms 2532 KB Output is correct
16 Correct 40 ms 2680 KB Output is correct
17 Correct 40 ms 2520 KB Output is correct
18 Correct 43 ms 2508 KB Output is correct
19 Correct 40 ms 2632 KB Output is correct
20 Correct 37 ms 2568 KB Output is correct
21 Correct 61 ms 2572 KB Output is correct
22 Correct 84 ms 2704 KB Output is correct
23 Correct 86 ms 2840 KB Output is correct
24 Correct 96 ms 2696 KB Output is correct
25 Correct 87 ms 2852 KB Output is correct
26 Correct 97 ms 2772 KB Output is correct
27 Correct 93 ms 2760 KB Output is correct
28 Correct 87 ms 2748 KB Output is correct
29 Correct 130 ms 2744 KB Output is correct
30 Correct 168 ms 2844 KB Output is correct
31 Correct 162 ms 3008 KB Output is correct
32 Correct 167 ms 2832 KB Output is correct
33 Correct 182 ms 2848 KB Output is correct
34 Correct 176 ms 2828 KB Output is correct
35 Correct 178 ms 2864 KB Output is correct
36 Correct 175 ms 2840 KB Output is correct
37 Correct 236 ms 3208 KB Output is correct
38 Correct 292 ms 3336 KB Output is correct
39 Correct 288 ms 3240 KB Output is correct
40 Correct 303 ms 3324 KB Output is correct
41 Correct 302 ms 3336 KB Output is correct
42 Correct 305 ms 3264 KB Output is correct
43 Correct 315 ms 3184 KB Output is correct
44 Correct 298 ms 3176 KB Output is correct
45 Correct 395 ms 3260 KB Output is correct
46 Runtime error 36 ms 680 KB Execution killed with signal 6
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
14 Correct 32 ms 2460 KB Output is correct
15 Correct 41 ms 2532 KB Output is correct
16 Correct 40 ms 2680 KB Output is correct
17 Correct 40 ms 2520 KB Output is correct
18 Correct 43 ms 2508 KB Output is correct
19 Correct 40 ms 2632 KB Output is correct
20 Correct 37 ms 2568 KB Output is correct
21 Correct 61 ms 2572 KB Output is correct
22 Correct 84 ms 2704 KB Output is correct
23 Correct 86 ms 2840 KB Output is correct
24 Correct 96 ms 2696 KB Output is correct
25 Correct 87 ms 2852 KB Output is correct
26 Correct 97 ms 2772 KB Output is correct
27 Correct 93 ms 2760 KB Output is correct
28 Correct 87 ms 2748 KB Output is correct
29 Correct 130 ms 2744 KB Output is correct
30 Correct 168 ms 2844 KB Output is correct
31 Correct 162 ms 3008 KB Output is correct
32 Correct 167 ms 2832 KB Output is correct
33 Correct 182 ms 2848 KB Output is correct
34 Correct 176 ms 2828 KB Output is correct
35 Correct 178 ms 2864 KB Output is correct
36 Correct 175 ms 2840 KB Output is correct
37 Correct 236 ms 3208 KB Output is correct
38 Correct 292 ms 3336 KB Output is correct
39 Correct 288 ms 3240 KB Output is correct
40 Correct 303 ms 3324 KB Output is correct
41 Correct 302 ms 3336 KB Output is correct
42 Correct 305 ms 3264 KB Output is correct
43 Correct 315 ms 3184 KB Output is correct
44 Correct 298 ms 3176 KB Output is correct
45 Correct 395 ms 3260 KB Output is correct
46 Runtime error 36 ms 680 KB Execution killed with signal 6
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
14 Correct 32 ms 2460 KB Output is correct
15 Correct 41 ms 2532 KB Output is correct
16 Correct 40 ms 2680 KB Output is correct
17 Correct 40 ms 2520 KB Output is correct
18 Correct 43 ms 2508 KB Output is correct
19 Correct 40 ms 2632 KB Output is correct
20 Correct 37 ms 2568 KB Output is correct
21 Correct 61 ms 2572 KB Output is correct
22 Correct 84 ms 2704 KB Output is correct
23 Correct 86 ms 2840 KB Output is correct
24 Correct 96 ms 2696 KB Output is correct
25 Correct 87 ms 2852 KB Output is correct
26 Correct 97 ms 2772 KB Output is correct
27 Correct 93 ms 2760 KB Output is correct
28 Correct 87 ms 2748 KB Output is correct
29 Correct 130 ms 2744 KB Output is correct
30 Correct 168 ms 2844 KB Output is correct
31 Correct 162 ms 3008 KB Output is correct
32 Correct 167 ms 2832 KB Output is correct
33 Correct 182 ms 2848 KB Output is correct
34 Correct 176 ms 2828 KB Output is correct
35 Correct 178 ms 2864 KB Output is correct
36 Correct 175 ms 2840 KB Output is correct
37 Correct 236 ms 3208 KB Output is correct
38 Correct 292 ms 3336 KB Output is correct
39 Correct 288 ms 3240 KB Output is correct
40 Correct 303 ms 3324 KB Output is correct
41 Correct 302 ms 3336 KB Output is correct
42 Correct 305 ms 3264 KB Output is correct
43 Correct 315 ms 3184 KB Output is correct
44 Correct 298 ms 3176 KB Output is correct
45 Correct 395 ms 3260 KB Output is correct
46 Runtime error 36 ms 680 KB Execution killed with signal 6
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 8 ms 1880 KB Output is correct
3 Correct 8 ms 2104 KB Output is correct
4 Correct 8 ms 1880 KB Output is correct
5 Correct 7 ms 1956 KB Output is correct
6 Correct 8 ms 1960 KB Output is correct
7 Correct 9 ms 2216 KB Output is correct
8 Correct 16 ms 1884 KB Output is correct
9 Correct 15 ms 1924 KB Output is correct
10 Correct 17 ms 2276 KB Output is correct
11 Correct 17 ms 2228 KB Output is correct
12 Correct 15 ms 2032 KB Output is correct
13 Correct 16 ms 1880 KB Output is correct
14 Correct 32 ms 2460 KB Output is correct
15 Correct 41 ms 2532 KB Output is correct
16 Correct 40 ms 2680 KB Output is correct
17 Correct 40 ms 2520 KB Output is correct
18 Correct 43 ms 2508 KB Output is correct
19 Correct 40 ms 2632 KB Output is correct
20 Correct 37 ms 2568 KB Output is correct
21 Correct 61 ms 2572 KB Output is correct
22 Correct 84 ms 2704 KB Output is correct
23 Correct 86 ms 2840 KB Output is correct
24 Correct 96 ms 2696 KB Output is correct
25 Correct 87 ms 2852 KB Output is correct
26 Correct 97 ms 2772 KB Output is correct
27 Correct 93 ms 2760 KB Output is correct
28 Correct 87 ms 2748 KB Output is correct
29 Correct 130 ms 2744 KB Output is correct
30 Correct 168 ms 2844 KB Output is correct
31 Correct 162 ms 3008 KB Output is correct
32 Correct 167 ms 2832 KB Output is correct
33 Correct 182 ms 2848 KB Output is correct
34 Correct 176 ms 2828 KB Output is correct
35 Correct 178 ms 2864 KB Output is correct
36 Correct 175 ms 2840 KB Output is correct
37 Correct 236 ms 3208 KB Output is correct
38 Correct 292 ms 3336 KB Output is correct
39 Correct 288 ms 3240 KB Output is correct
40 Correct 303 ms 3324 KB Output is correct
41 Correct 302 ms 3336 KB Output is correct
42 Correct 305 ms 3264 KB Output is correct
43 Correct 315 ms 3184 KB Output is correct
44 Correct 298 ms 3176 KB Output is correct
45 Correct 395 ms 3260 KB Output is correct
46 Runtime error 36 ms 680 KB Execution killed with signal 6
47 Halted 0 ms 0 KB -