Submission #573696

# Submission time Handle Problem Language Result Execution time Memory
573696 2022-06-07T05:37:29 Z teraqqq Mars (APIO22_mars) C++17
100 / 100
1449 ms 4964 KB
#include "mars.h"

#include <numeric>
#include <iostream>
#include <map>

using namespace std;
using pi = pair<int, int>;

struct Dsu {
	vector<int> p, c;

	Dsu (int n) : p(n), c(n, 1) {
		iota(p.begin(), p.end(), 0);
	}

	int root(int v) {
		return v == p[v] ? v : p[v] = root(p[v]);
	}

	bool unite(int a, int b) {
		a = root(a), b = root(b);
		if (a == b) {
			return false;
		} else {
			if (c[a] < c[b]) swap(a, b);
			p[b] = a;
			c[a] += c[b];
			return true;
		}
	}
};

vector<int> get_colors(vector<string> v, vector<int> info, int& additional_cost, vector<int>& slice, int& slice_diff) {
	const int n = v.size();
	Dsu dsu(n*n);

	vector<pi> bound;

	for (int i = n - 1; i >= 2; --i) bound.emplace_back(i, 2);
	for (int i = 3; i < n; ++i) bound.emplace_back(2, i);

	vector<int> st_colors;
	for (int i = 0; i < bound.size(); ++i) {
		auto [x, y] = bound[i];
		if (v[x][y] == '1') {
			if (info[i]) {
				st_colors.push_back(n*x + y);
			} else {
				dsu.unite(st_colors.back(), n*x+y);
			}
		} else {
			if (info[i]) st_colors.pop_back();
		}
	}

	for (int i = 0; i < n; ++i)
	for (int j = 0; j < n; ++j) {
		if (v[i][j] != '1') continue;
		const int s = n*i + j;
		if (i + 1 < n && v[i+1][j] == '1') dsu.unite(s, s+n);
		if (j + 1 < n && v[i][j+1] == '1') dsu.unite(s, s+1);
	}

	vector<int> used(n*n);
	for (int i = 0; i < n; ++i) {
		if (v[0][i] == '1' && !used[dsu.root(i)])   used[dsu.root(i)]   = 1, ++slice_diff;
		if (v[i][0] == '1' && !used[dsu.root(i*n)]) used[dsu.root(i*n)] = 1, ++slice_diff;
	}

	for (int i = 1; i < n; ++i)
	for (int j = 1; j < n; ++j) {
		if (v[i][j] == '0') continue;
		int rt = dsu.root(n*i+j);
		if (!used[rt]) ++additional_cost;
		used[rt] = 1;
	}

	bound.clear();
	for (int i = n - 1; i >= 0; --i) bound.emplace_back(i, 0);
	for (int i = 1; i < n; ++i) bound.emplace_back(0, i);

	vector<int> res;
	for (auto [x, y] : bound) {
		res.push_back(dsu.root(n*x+y));
		slice.push_back(v[x][y] - '0');
	}
	return res;
}

void write_cost(string& res, int cost) {
	for (int i = 0; i < 11; ++i) {
		res[i+1] = (cost >> i) % 2 ? '1' : '0';
	}
}

string get_answer(int ans) {
	string res(100, '0');
	for (int i = 0; i < 20; ++i) {
		res[i] = '0' + (ans >> i) % 2;
	}
	return res;
}

int load_cost(string& res) {
	int cost = 0;
	for (int i = 0; i < 11; ++i) {
		cost += (res[i+1] - '0') << i;
	}
	return cost;
}

vector<int> get_mask_by_color(vector<int> cols, vector<int> slice) {
	const int n = cols.size();

	vector<int> res(n+1), st;

	for (int i = 0; i < n; ++i) {
		if (slice[i] == 0 || cols[i] == -1) continue;

		int last = i;
		for (int j = i + 1; j < n; ++j) {
			if (cols[j] == cols[i]) {
				cols[j] = -1;
				last = j;
			}
		}

		res[i] = 1;
		res[last+1] = 1;
	}

	return res;
}

string process(vector<vector<string>> a, int i, int j, int k, int n) {
	const vector<pi> dpos = { {-1,0}, {1,0}, {0,1}, {0,-1} };
	if (max(i, j) != 2 * (n-k-1)) return a[0][0];

	string res(100, '0');

	const int w = 2 * k + 3;

	if (max(i, j) == 2*n-2) {
		if (i == j) {
			vector<int> info { 1, 1 }, slice;
			vector v(3, string(3, '0'));
			for (int i = 3; i--; )
			for (int j = 3; j--; ) v[i][j] = a[i][j][0];

			int cost = 0, slice_diff = 0;
			auto cols = get_colors(v, info, cost, slice, slice_diff);
			auto info_write = get_mask_by_color(cols, slice);
			res[0] = a[0][0][0];
			write_cost(res, cost);
			for (int i = 0; i < info_write.size(); ++i) res[i+12] = info_write[i] + '0';

			if (i == 0) return get_answer(cost + slice_diff);
			return res;
		} else {
			if (i == 2*n-2 && j % 2 == 0) {
				res[0] = a[0][0][0];
				res[1] = a[1][0][0];
				res[2] = a[2][0][0];
				res[3] = a[0][1][0];
				res[4] = a[1][1][0];
				res[5] = a[2][1][0];
				return res;
			}

			if (j == 2*n-2 && i % 2 == 0) {
				res[0] = a[0][0][0];
				res[1] = a[0][1][0];
				res[2] = a[0][2][0];
				res[3] = a[1][0][0];
				res[4] = a[1][1][0];
				res[5] = a[1][2][0];
				return res;
			}

			if (i == 2*n-2 && j == 2*n-3) {
				res[0] = a[0][0][0];
				res[1] = a[0][1][0];
				res[2] = a[1][1][0];
				res[3] = a[2][1][0];
				return res;
			}

			if (i == 2*n-3 && j == 2*n-2) {
				res[0] = a[0][0][0];
				res[1] = a[1][0][0];
				res[2] = a[1][1][0];
				res[3] = a[1][2][0];
				return res;
			}
		}
	} else if (max(i, j) == 2*(n-k)-2) {
		if (i == j) {
			int cost = load_cost(a[2][2]);

			vector v(w, string(w, '0'));
			v[0][0] = a[0][0][0];
			v[0][1] = a[0][1][0];
			v[1][0] = a[1][0][0];
			v[1][1] = a[1][1][0];
			v[2][2] = a[2][2][0];

			const int W = w - 2;
			for (int i = 0; i < W; ++i) {
				v[i+2][0] = a[2][0][i];
				v[i+2][1] = a[2][0][i+W];
				v[0][i+2] = a[0][2][i];
				v[1][i+2] = a[0][2][i+W];
			}

			// cerr << a[2][1] << endl;

			for (int i = 0; i < W; ++i) {
				v[i+2][2] = a[2][1][i+1];
				v[2][2+i] = a[1][2][i+1];
			}

			vector<int> info(2*W), slice;
			for (int i = 0; i < 2*W; ++i) info[i] = a[2][2][i+12] - '0';

			int slice_cost = 0;
			auto cols = get_colors(v, info, cost, slice, slice_cost);
			auto info_write = get_mask_by_color(cols, slice);
			res[0] = a[0][0][0];
			write_cost(res, cost);
			for (int i = 0; i < info_write.size(); ++i) res[i+12] = info_write[i] + '0';
			if (i == 0) return get_answer(cost + slice_cost);
			return res;
		} else {
			if (i == 2*(n-k)-2 && j % 2 == 0) {
				res[0] = a[0][0][0];
				res[1] = a[1][0][0];
				for (int i = 2; i < w; ++i) {
					res[i] = a[2][0][i-2];
				}
				res[w]   = a[0][1][0];
				res[w+1] = a[1][1][0];
				for (int i = 2; i < w; ++i) {
					res[i+w] = a[2][0][i+w-4];
				}
				return res;
			}

			if (j == 2*(n-k)-2 && i % 2 == 0) {
				res[0] = a[0][0][0];
				res[1] = a[0][1][0];
				for (int i = 2; i < w; ++i) {
					res[i] = a[0][2][i-2];
				}
				res[w]   = a[1][0][0];
				res[w+1] = a[1][1][0];
				for (int i = 2; i < w; ++i) {
					res[i+w] = a[0][2][i+w-4];
				}
				return res;
			}

			if (i == 2*(n-k)-2 && j == 2*(n-k)-3) {
				res[0] = a[0][0][0];
				res[1] = a[0][1][0];
				res[2] = a[1][1][0];
				for (int i = 0; i < w-2; ++i) {
					res[i+3] = a[2][1][i];
				}
				return res;
			}

			if (j == 2*(n-k)-2 && i == 2*(n-k)-3) {
				res[0] = a[0][0][0];
				res[1] = a[1][0][0];
				res[2] = a[1][1][0];
				for (int i = 0; i < w-2; ++i) {
					res[i+3] = a[1][2][i];
				}
				return res;
			}
		}
	}

	return a[0][0];
}

Compilation message

mars.cpp: In function 'std::vector<int> get_colors(std::vector<std::__cxx11::basic_string<char> >, std::vector<int>, int&, std::vector<int>&, int&)':
mars.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for (int i = 0; i < bound.size(); ++i) {
      |                  ~~^~~~~~~~~~~~~~
mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:156:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  156 |    for (int i = 0; i < info_write.size(); ++i) res[i+12] = info_write[i] + '0';
      |                    ~~^~~~~~~~~~~~~~~~~~~
mars.cpp:231:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  231 |    for (int i = 0; i < info_write.size(); ++i) res[i+12] = info_write[i] + '0';
      |                    ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
14 Correct 30 ms 2492 KB Output is correct
15 Correct 47 ms 2464 KB Output is correct
16 Correct 40 ms 2504 KB Output is correct
17 Correct 41 ms 2528 KB Output is correct
18 Correct 41 ms 2472 KB Output is correct
19 Correct 40 ms 2576 KB Output is correct
20 Correct 43 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
14 Correct 30 ms 2492 KB Output is correct
15 Correct 47 ms 2464 KB Output is correct
16 Correct 40 ms 2504 KB Output is correct
17 Correct 41 ms 2528 KB Output is correct
18 Correct 41 ms 2472 KB Output is correct
19 Correct 40 ms 2576 KB Output is correct
20 Correct 43 ms 2680 KB Output is correct
21 Correct 66 ms 2584 KB Output is correct
22 Correct 91 ms 2652 KB Output is correct
23 Correct 83 ms 2516 KB Output is correct
24 Correct 93 ms 2664 KB Output is correct
25 Correct 86 ms 2548 KB Output is correct
26 Correct 94 ms 2712 KB Output is correct
27 Correct 89 ms 2656 KB Output is correct
28 Correct 88 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
14 Correct 30 ms 2492 KB Output is correct
15 Correct 47 ms 2464 KB Output is correct
16 Correct 40 ms 2504 KB Output is correct
17 Correct 41 ms 2528 KB Output is correct
18 Correct 41 ms 2472 KB Output is correct
19 Correct 40 ms 2576 KB Output is correct
20 Correct 43 ms 2680 KB Output is correct
21 Correct 66 ms 2584 KB Output is correct
22 Correct 91 ms 2652 KB Output is correct
23 Correct 83 ms 2516 KB Output is correct
24 Correct 93 ms 2664 KB Output is correct
25 Correct 86 ms 2548 KB Output is correct
26 Correct 94 ms 2712 KB Output is correct
27 Correct 89 ms 2656 KB Output is correct
28 Correct 88 ms 2688 KB Output is correct
29 Correct 126 ms 2776 KB Output is correct
30 Correct 168 ms 2848 KB Output is correct
31 Correct 163 ms 2836 KB Output is correct
32 Correct 175 ms 2944 KB Output is correct
33 Correct 163 ms 2960 KB Output is correct
34 Correct 168 ms 2940 KB Output is correct
35 Correct 162 ms 2852 KB Output is correct
36 Correct 170 ms 2812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
14 Correct 30 ms 2492 KB Output is correct
15 Correct 47 ms 2464 KB Output is correct
16 Correct 40 ms 2504 KB Output is correct
17 Correct 41 ms 2528 KB Output is correct
18 Correct 41 ms 2472 KB Output is correct
19 Correct 40 ms 2576 KB Output is correct
20 Correct 43 ms 2680 KB Output is correct
21 Correct 66 ms 2584 KB Output is correct
22 Correct 91 ms 2652 KB Output is correct
23 Correct 83 ms 2516 KB Output is correct
24 Correct 93 ms 2664 KB Output is correct
25 Correct 86 ms 2548 KB Output is correct
26 Correct 94 ms 2712 KB Output is correct
27 Correct 89 ms 2656 KB Output is correct
28 Correct 88 ms 2688 KB Output is correct
29 Correct 126 ms 2776 KB Output is correct
30 Correct 168 ms 2848 KB Output is correct
31 Correct 163 ms 2836 KB Output is correct
32 Correct 175 ms 2944 KB Output is correct
33 Correct 163 ms 2960 KB Output is correct
34 Correct 168 ms 2940 KB Output is correct
35 Correct 162 ms 2852 KB Output is correct
36 Correct 170 ms 2812 KB Output is correct
37 Correct 213 ms 3260 KB Output is correct
38 Correct 289 ms 3404 KB Output is correct
39 Correct 296 ms 3376 KB Output is correct
40 Correct 278 ms 3228 KB Output is correct
41 Correct 300 ms 3260 KB Output is correct
42 Correct 284 ms 3204 KB Output is correct
43 Correct 269 ms 3312 KB Output is correct
44 Correct 298 ms 3200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
14 Correct 30 ms 2492 KB Output is correct
15 Correct 47 ms 2464 KB Output is correct
16 Correct 40 ms 2504 KB Output is correct
17 Correct 41 ms 2528 KB Output is correct
18 Correct 41 ms 2472 KB Output is correct
19 Correct 40 ms 2576 KB Output is correct
20 Correct 43 ms 2680 KB Output is correct
21 Correct 66 ms 2584 KB Output is correct
22 Correct 91 ms 2652 KB Output is correct
23 Correct 83 ms 2516 KB Output is correct
24 Correct 93 ms 2664 KB Output is correct
25 Correct 86 ms 2548 KB Output is correct
26 Correct 94 ms 2712 KB Output is correct
27 Correct 89 ms 2656 KB Output is correct
28 Correct 88 ms 2688 KB Output is correct
29 Correct 126 ms 2776 KB Output is correct
30 Correct 168 ms 2848 KB Output is correct
31 Correct 163 ms 2836 KB Output is correct
32 Correct 175 ms 2944 KB Output is correct
33 Correct 163 ms 2960 KB Output is correct
34 Correct 168 ms 2940 KB Output is correct
35 Correct 162 ms 2852 KB Output is correct
36 Correct 170 ms 2812 KB Output is correct
37 Correct 213 ms 3260 KB Output is correct
38 Correct 289 ms 3404 KB Output is correct
39 Correct 296 ms 3376 KB Output is correct
40 Correct 278 ms 3228 KB Output is correct
41 Correct 300 ms 3260 KB Output is correct
42 Correct 284 ms 3204 KB Output is correct
43 Correct 269 ms 3312 KB Output is correct
44 Correct 298 ms 3200 KB Output is correct
45 Correct 353 ms 3404 KB Output is correct
46 Correct 435 ms 3412 KB Output is correct
47 Correct 452 ms 3568 KB Output is correct
48 Correct 458 ms 3428 KB Output is correct
49 Correct 438 ms 3364 KB Output is correct
50 Correct 448 ms 3512 KB Output is correct
51 Correct 447 ms 3408 KB Output is correct
52 Correct 439 ms 3464 KB Output is correct
53 Correct 432 ms 3424 KB Output is correct
54 Correct 447 ms 3592 KB Output is correct
55 Correct 446 ms 3532 KB Output is correct
56 Correct 449 ms 3504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
14 Correct 30 ms 2492 KB Output is correct
15 Correct 47 ms 2464 KB Output is correct
16 Correct 40 ms 2504 KB Output is correct
17 Correct 41 ms 2528 KB Output is correct
18 Correct 41 ms 2472 KB Output is correct
19 Correct 40 ms 2576 KB Output is correct
20 Correct 43 ms 2680 KB Output is correct
21 Correct 66 ms 2584 KB Output is correct
22 Correct 91 ms 2652 KB Output is correct
23 Correct 83 ms 2516 KB Output is correct
24 Correct 93 ms 2664 KB Output is correct
25 Correct 86 ms 2548 KB Output is correct
26 Correct 94 ms 2712 KB Output is correct
27 Correct 89 ms 2656 KB Output is correct
28 Correct 88 ms 2688 KB Output is correct
29 Correct 126 ms 2776 KB Output is correct
30 Correct 168 ms 2848 KB Output is correct
31 Correct 163 ms 2836 KB Output is correct
32 Correct 175 ms 2944 KB Output is correct
33 Correct 163 ms 2960 KB Output is correct
34 Correct 168 ms 2940 KB Output is correct
35 Correct 162 ms 2852 KB Output is correct
36 Correct 170 ms 2812 KB Output is correct
37 Correct 213 ms 3260 KB Output is correct
38 Correct 289 ms 3404 KB Output is correct
39 Correct 296 ms 3376 KB Output is correct
40 Correct 278 ms 3228 KB Output is correct
41 Correct 300 ms 3260 KB Output is correct
42 Correct 284 ms 3204 KB Output is correct
43 Correct 269 ms 3312 KB Output is correct
44 Correct 298 ms 3200 KB Output is correct
45 Correct 353 ms 3404 KB Output is correct
46 Correct 435 ms 3412 KB Output is correct
47 Correct 452 ms 3568 KB Output is correct
48 Correct 458 ms 3428 KB Output is correct
49 Correct 438 ms 3364 KB Output is correct
50 Correct 448 ms 3512 KB Output is correct
51 Correct 447 ms 3408 KB Output is correct
52 Correct 439 ms 3464 KB Output is correct
53 Correct 432 ms 3424 KB Output is correct
54 Correct 447 ms 3592 KB Output is correct
55 Correct 446 ms 3532 KB Output is correct
56 Correct 449 ms 3504 KB Output is correct
57 Correct 562 ms 3996 KB Output is correct
58 Correct 671 ms 4044 KB Output is correct
59 Correct 657 ms 4052 KB Output is correct
60 Correct 660 ms 3948 KB Output is correct
61 Correct 661 ms 4144 KB Output is correct
62 Correct 666 ms 4228 KB Output is correct
63 Correct 679 ms 4068 KB Output is correct
64 Correct 691 ms 4024 KB Output is correct
65 Correct 657 ms 3968 KB Output is correct
66 Correct 669 ms 3968 KB Output is correct
67 Correct 671 ms 3912 KB Output is correct
68 Correct 683 ms 4144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
14 Correct 30 ms 2492 KB Output is correct
15 Correct 47 ms 2464 KB Output is correct
16 Correct 40 ms 2504 KB Output is correct
17 Correct 41 ms 2528 KB Output is correct
18 Correct 41 ms 2472 KB Output is correct
19 Correct 40 ms 2576 KB Output is correct
20 Correct 43 ms 2680 KB Output is correct
21 Correct 66 ms 2584 KB Output is correct
22 Correct 91 ms 2652 KB Output is correct
23 Correct 83 ms 2516 KB Output is correct
24 Correct 93 ms 2664 KB Output is correct
25 Correct 86 ms 2548 KB Output is correct
26 Correct 94 ms 2712 KB Output is correct
27 Correct 89 ms 2656 KB Output is correct
28 Correct 88 ms 2688 KB Output is correct
29 Correct 126 ms 2776 KB Output is correct
30 Correct 168 ms 2848 KB Output is correct
31 Correct 163 ms 2836 KB Output is correct
32 Correct 175 ms 2944 KB Output is correct
33 Correct 163 ms 2960 KB Output is correct
34 Correct 168 ms 2940 KB Output is correct
35 Correct 162 ms 2852 KB Output is correct
36 Correct 170 ms 2812 KB Output is correct
37 Correct 213 ms 3260 KB Output is correct
38 Correct 289 ms 3404 KB Output is correct
39 Correct 296 ms 3376 KB Output is correct
40 Correct 278 ms 3228 KB Output is correct
41 Correct 300 ms 3260 KB Output is correct
42 Correct 284 ms 3204 KB Output is correct
43 Correct 269 ms 3312 KB Output is correct
44 Correct 298 ms 3200 KB Output is correct
45 Correct 353 ms 3404 KB Output is correct
46 Correct 435 ms 3412 KB Output is correct
47 Correct 452 ms 3568 KB Output is correct
48 Correct 458 ms 3428 KB Output is correct
49 Correct 438 ms 3364 KB Output is correct
50 Correct 448 ms 3512 KB Output is correct
51 Correct 447 ms 3408 KB Output is correct
52 Correct 439 ms 3464 KB Output is correct
53 Correct 432 ms 3424 KB Output is correct
54 Correct 447 ms 3592 KB Output is correct
55 Correct 446 ms 3532 KB Output is correct
56 Correct 449 ms 3504 KB Output is correct
57 Correct 562 ms 3996 KB Output is correct
58 Correct 671 ms 4044 KB Output is correct
59 Correct 657 ms 4052 KB Output is correct
60 Correct 660 ms 3948 KB Output is correct
61 Correct 661 ms 4144 KB Output is correct
62 Correct 666 ms 4228 KB Output is correct
63 Correct 679 ms 4068 KB Output is correct
64 Correct 691 ms 4024 KB Output is correct
65 Correct 657 ms 3968 KB Output is correct
66 Correct 669 ms 3968 KB Output is correct
67 Correct 671 ms 3912 KB Output is correct
68 Correct 683 ms 4144 KB Output is correct
69 Correct 797 ms 4216 KB Output is correct
70 Correct 961 ms 4288 KB Output is correct
71 Correct 941 ms 4264 KB Output is correct
72 Correct 974 ms 4352 KB Output is correct
73 Correct 967 ms 4284 KB Output is correct
74 Correct 966 ms 4312 KB Output is correct
75 Correct 930 ms 4296 KB Output is correct
76 Correct 1053 ms 4216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2028 KB Output is correct
2 Correct 7 ms 1968 KB Output is correct
3 Correct 8 ms 2140 KB Output is correct
4 Correct 8 ms 1964 KB Output is correct
5 Correct 8 ms 1972 KB Output is correct
6 Correct 8 ms 2064 KB Output is correct
7 Correct 10 ms 1944 KB Output is correct
8 Correct 18 ms 2092 KB Output is correct
9 Correct 16 ms 2004 KB Output is correct
10 Correct 16 ms 2040 KB Output is correct
11 Correct 16 ms 2064 KB Output is correct
12 Correct 19 ms 1968 KB Output is correct
13 Correct 16 ms 2120 KB Output is correct
14 Correct 30 ms 2492 KB Output is correct
15 Correct 47 ms 2464 KB Output is correct
16 Correct 40 ms 2504 KB Output is correct
17 Correct 41 ms 2528 KB Output is correct
18 Correct 41 ms 2472 KB Output is correct
19 Correct 40 ms 2576 KB Output is correct
20 Correct 43 ms 2680 KB Output is correct
21 Correct 66 ms 2584 KB Output is correct
22 Correct 91 ms 2652 KB Output is correct
23 Correct 83 ms 2516 KB Output is correct
24 Correct 93 ms 2664 KB Output is correct
25 Correct 86 ms 2548 KB Output is correct
26 Correct 94 ms 2712 KB Output is correct
27 Correct 89 ms 2656 KB Output is correct
28 Correct 88 ms 2688 KB Output is correct
29 Correct 126 ms 2776 KB Output is correct
30 Correct 168 ms 2848 KB Output is correct
31 Correct 163 ms 2836 KB Output is correct
32 Correct 175 ms 2944 KB Output is correct
33 Correct 163 ms 2960 KB Output is correct
34 Correct 168 ms 2940 KB Output is correct
35 Correct 162 ms 2852 KB Output is correct
36 Correct 170 ms 2812 KB Output is correct
37 Correct 213 ms 3260 KB Output is correct
38 Correct 289 ms 3404 KB Output is correct
39 Correct 296 ms 3376 KB Output is correct
40 Correct 278 ms 3228 KB Output is correct
41 Correct 300 ms 3260 KB Output is correct
42 Correct 284 ms 3204 KB Output is correct
43 Correct 269 ms 3312 KB Output is correct
44 Correct 298 ms 3200 KB Output is correct
45 Correct 353 ms 3404 KB Output is correct
46 Correct 435 ms 3412 KB Output is correct
47 Correct 452 ms 3568 KB Output is correct
48 Correct 458 ms 3428 KB Output is correct
49 Correct 438 ms 3364 KB Output is correct
50 Correct 448 ms 3512 KB Output is correct
51 Correct 447 ms 3408 KB Output is correct
52 Correct 439 ms 3464 KB Output is correct
53 Correct 432 ms 3424 KB Output is correct
54 Correct 447 ms 3592 KB Output is correct
55 Correct 446 ms 3532 KB Output is correct
56 Correct 449 ms 3504 KB Output is correct
57 Correct 562 ms 3996 KB Output is correct
58 Correct 671 ms 4044 KB Output is correct
59 Correct 657 ms 4052 KB Output is correct
60 Correct 660 ms 3948 KB Output is correct
61 Correct 661 ms 4144 KB Output is correct
62 Correct 666 ms 4228 KB Output is correct
63 Correct 679 ms 4068 KB Output is correct
64 Correct 691 ms 4024 KB Output is correct
65 Correct 657 ms 3968 KB Output is correct
66 Correct 669 ms 3968 KB Output is correct
67 Correct 671 ms 3912 KB Output is correct
68 Correct 683 ms 4144 KB Output is correct
69 Correct 797 ms 4216 KB Output is correct
70 Correct 961 ms 4288 KB Output is correct
71 Correct 941 ms 4264 KB Output is correct
72 Correct 974 ms 4352 KB Output is correct
73 Correct 967 ms 4284 KB Output is correct
74 Correct 966 ms 4312 KB Output is correct
75 Correct 930 ms 4296 KB Output is correct
76 Correct 1053 ms 4216 KB Output is correct
77 Correct 1030 ms 4168 KB Output is correct
78 Correct 1449 ms 4964 KB Output is correct
79 Correct 1434 ms 4780 KB Output is correct
80 Correct 1407 ms 4780 KB Output is correct
81 Correct 1392 ms 4632 KB Output is correct
82 Correct 1316 ms 4636 KB Output is correct
83 Correct 1396 ms 4704 KB Output is correct
84 Correct 1374 ms 4616 KB Output is correct