Submission #726205

# Submission time Handle Problem Language Result Execution time Memory
726205 2023-04-18T16:40:57 Z hollwo_pelw Mars (APIO22_mars) C++17
100 / 100
3395 ms 5700 KB
#include "mars.h"

#ifdef hollwo_pelw_local
#include "grader.cpp"
#endif

#include <bits/stdc++.h>
using namespace std;

const int N = 50;

#define pii pair<int, int> 
#define x first
#define y second

bool board[N][N];
int vis[N][N];
vector<pii> adj[N][N]; // boundary of 4 corners

const int dx[] = {-1, 0, +1, 0};
const int dy[] = {0, -1, 0, +1};

void dfs(int x, int y) {
	for (int d = 0; d < 4; d++) {
		int nx = x + dx[d], ny = y + dy[d];
		if (nx < 0 || ny < 0) continue;
		if (board[nx][ny] && vis[nx][ny] == -1)
			vis[nx][ny] = vis[x][y], dfs(nx, ny);
	}

	for (auto [nx, ny] : adj[x][y]) {
		if (board[nx][ny] && vis[nx][ny] == -1)
			vis[nx][ny] = vis[x][y], dfs(nx, ny);
	}
}

int decode(const string &s) {
	int v = 0, len = s.size();
	for (int i = 0; i < min(20, len); i++)
		v |= (s[i] == '1') << i;
	return v;
}

int decode(const string &s, int p, int len) {
	return decode(s.substr(p, len));
}

string encode(int len, int v) {
	// cout << "encode " << len << ' ' << v << '\n';
	string res(len, '0');
	for (int i = 0; i < min(20, len); i++)
		res[i] = "01"[v >> i & 1];
	// cout << res << '\n';
	return res;
}

string process(vector<vector<string>> s, int i, int j, int k, int n) {
	memset(vis, -1, sizeof vis);
	memset(board, 0, sizeof board);

	for (int i = 0; i <= 2 * n; i++) {
		for (int j = 0; j <= 2 * n; j++)
			adj[i][j].clear();
	}

	if (n == 1) {
		for (int i = 0; i <= 2 * n; i++) {
			for (int j = 0; j <= 2 * n; j++) {
				board[i][j] = s[i][j][0] == '1';
			}
		}

		int res = 0;
		for (int i = 0; i <= 2 * n; i++) for (int j = 0; j <= 2 * n; j++) {
			if (board[i][j] && vis[i][j] == -1) {
				vis[i][j] = res ++, dfs(i, j);
			}
		}

		return encode(100, res);

	}

	pii cur[N][N], nxt[N][N];

	// cout << "PHRASE " << n << ' ' << k << " -> " << "x = " << i << ' ' << "y = " << j << '\n';

	for (int x = 0; x <= 2 * n; x++) {
		for (int y = 0; y <= 2 * n; y++) {
			cur[x][y] = {min(x * n / 2, x + 2 * k)      , min(y * n / 2, y + 2 * k)      };
			nxt[x][y] = {min(x * n / 2, x + 2 * (k + 1)), min(y * n / 2, y + 2 * (k + 1))};
			// cout << x << ' ' << y << " -> " << nxt[x][y].x << ' ' << nxt[x][y].y << '\n';
		}
	}

	vector<pii> bound[4];
	for (int i = 0; i <= n; i++) {
		bound[0].push_back({n, i});
		bound[1].push_back({n, n * 2 - i});
		bound[2].push_back({n, i});
		bound[3].push_back({n, n * 2 - i});
	}
	for (int i = 1; i <= n; i++) {
		bound[0].push_back({n - i, n});
		bound[1].push_back({n - i, n});
		bound[2].push_back({n + i, n});
		bound[3].push_back({n + i, n});
	}

	if (k == n - 1) {
		// solve last step
		int res = 0;
		for (int fx : {0, 2}) for (int fy : {0, 2}) {
			auto curbound = bound[fx + fy / 2];

			string mask = s[fx][fy].substr(0, 41);
			string A = s[fx][fy].substr(41, 21);
			string B = s[fx][fy].substr(62, 21);
			res += decode(s[fx][fy], 83, 17);

			// cout << s[fx][fy].substr(83, 17) << '\n';
			// cout << res << '\n';

			vector<int> comp;
			for (int i = 0; i <= 2 * n; i++) {
				if (mask[i] & 1) {
					auto [x, y] = curbound[i];
					board[x][y] = 1;
				}
				if ((mask[i] & 1) && (i == 0 || !(mask[i - 1] & 1)))
					comp.push_back(i);
			}

			vector<int> stk;

			// cout << "CORNER " << fx << ' ' << fy << '\n';

			for (int i = 0, m = comp.size(); i < m; i++) {
				if (A[i] & 1) {
					stk.push_back(i);
				} else {
					auto [x1, y1] = curbound[comp[stk.back()]];
					auto [x2, y2] = curbound[comp[i]];


					// cout << x1 << ' ' << y1 << " -> " << x2 << ' ' << y2 << '\n';

					adj[x1][y1].push_back({x2, y2});
					adj[x2][y2].push_back({x1, y1});
				}

				if (B[i] & 1) {
					stk.pop_back();
				}
			}
		}

		for (int i = 0; i <= 2 * n; i++) for (int j = 0; j <= 2 * n; j++) {
			if (board[i][j] && vis[i][j] == -1) {
				vis[i][j] = ++ res, dfs(i, j);
			}
		}

		return encode(100, res);
	}
	if (k == n - 2) {
		// solve second last
		if (i % 2 == 1 || j % 2 == 1)
			return string(100, '0');
		auto curbound = bound[i + j / 2];
		int xl = 0, xr = n, yl = 0, yr = n;
		if (i) xl += n, xr += n;
		if (j) yl += n, yr += n;

		// for (int i = 0; i < 3; i++) {
		// 	for (int j = 0; j < 3; j++)
		// 		cout << s[i][j] << '\n';
		// }

		for (int x = xl; x <= xr; x++) for (int y = yl; y <= yr; y++) {
			bool ok = 0;
			for (int fx = 3; fx --; ) for (int fy = 3; fy -- && !ok; ) {
				int ox = x - cur[i + fx][j + fy].x;
				int oy = y - cur[i + fx][j + fy].y;
				if (ox < 0 || oy < 0 || ox >= 10 || oy >= 10)
					continue;
				// cout << x << ' ' << y << " keep in " << ox << ' ' << oy << '\n';
				// cout << "-> " << s[fx][fy][ox * 10 + oy] << '\n';
				board[x][y] = s[fx][fy][ox * 10 + oy] == '1', ok = 1;
			}
			// cout << board[x][y];
			// if (y == yr) cout << '\n';
		}

		int cnt_oth = 0, cnt_bnd = 0;

		for (auto [x, y] : curbound) {
			if (board[x][y] && vis[x][y] == -1) {
				vis[x][y] = ++ cnt_bnd, dfs(x, y);
			}
		}

		// for (int x = xl; x <= xr; x++) for (int y = yl; y <= yr; y++) {
		// 	cout << vis[x][y] << "\t\n"[y == yr];
		// }

		for (int x = xl; x <= xr; x++) for (int y = yl; y <= yr; y++) {
			if (board[x][y] && vis[x][y] == -1)
				vis[x][y] = ++ cnt_oth, dfs(x, y);
		}

		// cout << cnt_bnd << '\n';
		// cout << cnt_oth << '\n';

		assert((int) curbound.size() == 2 * n + 1);

		string mask(41, '0'), A(21, '0'), B(21, '0');
		
		vector<pair<int, int>> comp;

		for (int i = 0; i <= 2 * n; i++) {
			auto [x, y] = curbound[i];
			mask[i] = "01"[board[x][y]];
			if ((mask[i] & 1) && (i == 0 || !(mask[i - 1] & 1)))
				comp.push_back({i, vis[x][y]});
			// cout << mask[i];
		}
		// cout << '\n';

		for (int i = 0, m = comp.size(); i < m; i++) {
			bool isA = 1, isB = 1;
			for (int j = 0; j < i; j++)
				isA &= comp[j].second != comp[i].second;
			for (int j = i + 1; j < m; j++)
				isB &= comp[j].second != comp[i].second;
			A[i] = "01"[isA], B[i] = "01"[isB];
		}

		// cout << comp.size() << "\n";
		// cout << mask << "\n" << A << "\n" << B << "\n";

		// mask = component
		// A = open bracket
		// B = close bracket
		return mask + A + B + encode(17, cnt_oth);
	}
	// solve other case
	
	// cout << cur[2][3].x << ' ' << cur[2][3].y << '\n';
	// cout << nxt[2][3].x << ' ' << nxt[2][3].y << '\n';

	string res(100, '0');
	for (int x = 0; x < 10; x++) for (int y = 0; y < 10; y++) {
		bool ok = 0;
		for (int fx = 3; fx --; ) for (int fy = 3; fy -- && !ok; ) {
			int ox = x + nxt[i][j].x - cur[i + fx][j + fy].x;
			int oy = y + nxt[i][j].y - cur[i + fx][j + fy].y;

			if (ox < 0 || ox >= 10 || oy < 0 || oy >= 10)
				continue;

			res[x * 10 + y] = s[fx][fy][ox * 10 + oy], ok = 1;
			// cout << "KEEP " << x << ' ' << y << " = " << res[x * 10 + y] << '\n';
		}
	}


	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
14 Correct 39 ms 3280 KB Output is correct
15 Correct 60 ms 3264 KB Output is correct
16 Correct 53 ms 3372 KB Output is correct
17 Correct 95 ms 3400 KB Output is correct
18 Correct 54 ms 3356 KB Output is correct
19 Correct 60 ms 3328 KB Output is correct
20 Correct 85 ms 3356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
14 Correct 39 ms 3280 KB Output is correct
15 Correct 60 ms 3264 KB Output is correct
16 Correct 53 ms 3372 KB Output is correct
17 Correct 95 ms 3400 KB Output is correct
18 Correct 54 ms 3356 KB Output is correct
19 Correct 60 ms 3328 KB Output is correct
20 Correct 85 ms 3356 KB Output is correct
21 Correct 89 ms 3412 KB Output is correct
22 Correct 151 ms 3616 KB Output is correct
23 Correct 137 ms 3592 KB Output is correct
24 Correct 154 ms 3624 KB Output is correct
25 Correct 151 ms 3600 KB Output is correct
26 Correct 143 ms 3720 KB Output is correct
27 Correct 136 ms 3572 KB Output is correct
28 Correct 199 ms 3636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
14 Correct 39 ms 3280 KB Output is correct
15 Correct 60 ms 3264 KB Output is correct
16 Correct 53 ms 3372 KB Output is correct
17 Correct 95 ms 3400 KB Output is correct
18 Correct 54 ms 3356 KB Output is correct
19 Correct 60 ms 3328 KB Output is correct
20 Correct 85 ms 3356 KB Output is correct
21 Correct 89 ms 3412 KB Output is correct
22 Correct 151 ms 3616 KB Output is correct
23 Correct 137 ms 3592 KB Output is correct
24 Correct 154 ms 3624 KB Output is correct
25 Correct 151 ms 3600 KB Output is correct
26 Correct 143 ms 3720 KB Output is correct
27 Correct 136 ms 3572 KB Output is correct
28 Correct 199 ms 3636 KB Output is correct
29 Correct 235 ms 3712 KB Output is correct
30 Correct 276 ms 3696 KB Output is correct
31 Correct 285 ms 3696 KB Output is correct
32 Correct 254 ms 3704 KB Output is correct
33 Correct 314 ms 3776 KB Output is correct
34 Correct 266 ms 3672 KB Output is correct
35 Correct 259 ms 3708 KB Output is correct
36 Correct 268 ms 3692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
14 Correct 39 ms 3280 KB Output is correct
15 Correct 60 ms 3264 KB Output is correct
16 Correct 53 ms 3372 KB Output is correct
17 Correct 95 ms 3400 KB Output is correct
18 Correct 54 ms 3356 KB Output is correct
19 Correct 60 ms 3328 KB Output is correct
20 Correct 85 ms 3356 KB Output is correct
21 Correct 89 ms 3412 KB Output is correct
22 Correct 151 ms 3616 KB Output is correct
23 Correct 137 ms 3592 KB Output is correct
24 Correct 154 ms 3624 KB Output is correct
25 Correct 151 ms 3600 KB Output is correct
26 Correct 143 ms 3720 KB Output is correct
27 Correct 136 ms 3572 KB Output is correct
28 Correct 199 ms 3636 KB Output is correct
29 Correct 235 ms 3712 KB Output is correct
30 Correct 276 ms 3696 KB Output is correct
31 Correct 285 ms 3696 KB Output is correct
32 Correct 254 ms 3704 KB Output is correct
33 Correct 314 ms 3776 KB Output is correct
34 Correct 266 ms 3672 KB Output is correct
35 Correct 259 ms 3708 KB Output is correct
36 Correct 268 ms 3692 KB Output is correct
37 Correct 340 ms 3944 KB Output is correct
38 Correct 444 ms 4132 KB Output is correct
39 Correct 444 ms 4048 KB Output is correct
40 Correct 437 ms 4096 KB Output is correct
41 Correct 448 ms 4232 KB Output is correct
42 Correct 461 ms 4064 KB Output is correct
43 Correct 456 ms 4196 KB Output is correct
44 Correct 475 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
14 Correct 39 ms 3280 KB Output is correct
15 Correct 60 ms 3264 KB Output is correct
16 Correct 53 ms 3372 KB Output is correct
17 Correct 95 ms 3400 KB Output is correct
18 Correct 54 ms 3356 KB Output is correct
19 Correct 60 ms 3328 KB Output is correct
20 Correct 85 ms 3356 KB Output is correct
21 Correct 89 ms 3412 KB Output is correct
22 Correct 151 ms 3616 KB Output is correct
23 Correct 137 ms 3592 KB Output is correct
24 Correct 154 ms 3624 KB Output is correct
25 Correct 151 ms 3600 KB Output is correct
26 Correct 143 ms 3720 KB Output is correct
27 Correct 136 ms 3572 KB Output is correct
28 Correct 199 ms 3636 KB Output is correct
29 Correct 235 ms 3712 KB Output is correct
30 Correct 276 ms 3696 KB Output is correct
31 Correct 285 ms 3696 KB Output is correct
32 Correct 254 ms 3704 KB Output is correct
33 Correct 314 ms 3776 KB Output is correct
34 Correct 266 ms 3672 KB Output is correct
35 Correct 259 ms 3708 KB Output is correct
36 Correct 268 ms 3692 KB Output is correct
37 Correct 340 ms 3944 KB Output is correct
38 Correct 444 ms 4132 KB Output is correct
39 Correct 444 ms 4048 KB Output is correct
40 Correct 437 ms 4096 KB Output is correct
41 Correct 448 ms 4232 KB Output is correct
42 Correct 461 ms 4064 KB Output is correct
43 Correct 456 ms 4196 KB Output is correct
44 Correct 475 ms 4180 KB Output is correct
45 Correct 622 ms 4292 KB Output is correct
46 Correct 817 ms 4440 KB Output is correct
47 Correct 788 ms 4284 KB Output is correct
48 Correct 865 ms 4416 KB Output is correct
49 Correct 899 ms 4444 KB Output is correct
50 Correct 915 ms 4480 KB Output is correct
51 Correct 869 ms 4304 KB Output is correct
52 Correct 911 ms 4360 KB Output is correct
53 Correct 888 ms 4504 KB Output is correct
54 Correct 814 ms 4316 KB Output is correct
55 Correct 900 ms 4328 KB Output is correct
56 Correct 910 ms 4380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
14 Correct 39 ms 3280 KB Output is correct
15 Correct 60 ms 3264 KB Output is correct
16 Correct 53 ms 3372 KB Output is correct
17 Correct 95 ms 3400 KB Output is correct
18 Correct 54 ms 3356 KB Output is correct
19 Correct 60 ms 3328 KB Output is correct
20 Correct 85 ms 3356 KB Output is correct
21 Correct 89 ms 3412 KB Output is correct
22 Correct 151 ms 3616 KB Output is correct
23 Correct 137 ms 3592 KB Output is correct
24 Correct 154 ms 3624 KB Output is correct
25 Correct 151 ms 3600 KB Output is correct
26 Correct 143 ms 3720 KB Output is correct
27 Correct 136 ms 3572 KB Output is correct
28 Correct 199 ms 3636 KB Output is correct
29 Correct 235 ms 3712 KB Output is correct
30 Correct 276 ms 3696 KB Output is correct
31 Correct 285 ms 3696 KB Output is correct
32 Correct 254 ms 3704 KB Output is correct
33 Correct 314 ms 3776 KB Output is correct
34 Correct 266 ms 3672 KB Output is correct
35 Correct 259 ms 3708 KB Output is correct
36 Correct 268 ms 3692 KB Output is correct
37 Correct 340 ms 3944 KB Output is correct
38 Correct 444 ms 4132 KB Output is correct
39 Correct 444 ms 4048 KB Output is correct
40 Correct 437 ms 4096 KB Output is correct
41 Correct 448 ms 4232 KB Output is correct
42 Correct 461 ms 4064 KB Output is correct
43 Correct 456 ms 4196 KB Output is correct
44 Correct 475 ms 4180 KB Output is correct
45 Correct 622 ms 4292 KB Output is correct
46 Correct 817 ms 4440 KB Output is correct
47 Correct 788 ms 4284 KB Output is correct
48 Correct 865 ms 4416 KB Output is correct
49 Correct 899 ms 4444 KB Output is correct
50 Correct 915 ms 4480 KB Output is correct
51 Correct 869 ms 4304 KB Output is correct
52 Correct 911 ms 4360 KB Output is correct
53 Correct 888 ms 4504 KB Output is correct
54 Correct 814 ms 4316 KB Output is correct
55 Correct 900 ms 4328 KB Output is correct
56 Correct 910 ms 4380 KB Output is correct
57 Correct 1165 ms 4636 KB Output is correct
58 Correct 1391 ms 4728 KB Output is correct
59 Correct 1226 ms 4800 KB Output is correct
60 Correct 1304 ms 4836 KB Output is correct
61 Correct 1276 ms 4872 KB Output is correct
62 Correct 1209 ms 4788 KB Output is correct
63 Correct 1182 ms 4716 KB Output is correct
64 Correct 1277 ms 4796 KB Output is correct
65 Correct 1236 ms 4756 KB Output is correct
66 Correct 1231 ms 4840 KB Output is correct
67 Correct 1226 ms 4720 KB Output is correct
68 Correct 1234 ms 4868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
14 Correct 39 ms 3280 KB Output is correct
15 Correct 60 ms 3264 KB Output is correct
16 Correct 53 ms 3372 KB Output is correct
17 Correct 95 ms 3400 KB Output is correct
18 Correct 54 ms 3356 KB Output is correct
19 Correct 60 ms 3328 KB Output is correct
20 Correct 85 ms 3356 KB Output is correct
21 Correct 89 ms 3412 KB Output is correct
22 Correct 151 ms 3616 KB Output is correct
23 Correct 137 ms 3592 KB Output is correct
24 Correct 154 ms 3624 KB Output is correct
25 Correct 151 ms 3600 KB Output is correct
26 Correct 143 ms 3720 KB Output is correct
27 Correct 136 ms 3572 KB Output is correct
28 Correct 199 ms 3636 KB Output is correct
29 Correct 235 ms 3712 KB Output is correct
30 Correct 276 ms 3696 KB Output is correct
31 Correct 285 ms 3696 KB Output is correct
32 Correct 254 ms 3704 KB Output is correct
33 Correct 314 ms 3776 KB Output is correct
34 Correct 266 ms 3672 KB Output is correct
35 Correct 259 ms 3708 KB Output is correct
36 Correct 268 ms 3692 KB Output is correct
37 Correct 340 ms 3944 KB Output is correct
38 Correct 444 ms 4132 KB Output is correct
39 Correct 444 ms 4048 KB Output is correct
40 Correct 437 ms 4096 KB Output is correct
41 Correct 448 ms 4232 KB Output is correct
42 Correct 461 ms 4064 KB Output is correct
43 Correct 456 ms 4196 KB Output is correct
44 Correct 475 ms 4180 KB Output is correct
45 Correct 622 ms 4292 KB Output is correct
46 Correct 817 ms 4440 KB Output is correct
47 Correct 788 ms 4284 KB Output is correct
48 Correct 865 ms 4416 KB Output is correct
49 Correct 899 ms 4444 KB Output is correct
50 Correct 915 ms 4480 KB Output is correct
51 Correct 869 ms 4304 KB Output is correct
52 Correct 911 ms 4360 KB Output is correct
53 Correct 888 ms 4504 KB Output is correct
54 Correct 814 ms 4316 KB Output is correct
55 Correct 900 ms 4328 KB Output is correct
56 Correct 910 ms 4380 KB Output is correct
57 Correct 1165 ms 4636 KB Output is correct
58 Correct 1391 ms 4728 KB Output is correct
59 Correct 1226 ms 4800 KB Output is correct
60 Correct 1304 ms 4836 KB Output is correct
61 Correct 1276 ms 4872 KB Output is correct
62 Correct 1209 ms 4788 KB Output is correct
63 Correct 1182 ms 4716 KB Output is correct
64 Correct 1277 ms 4796 KB Output is correct
65 Correct 1236 ms 4756 KB Output is correct
66 Correct 1231 ms 4840 KB Output is correct
67 Correct 1226 ms 4720 KB Output is correct
68 Correct 1234 ms 4868 KB Output is correct
69 Correct 1541 ms 5032 KB Output is correct
70 Correct 1892 ms 5004 KB Output is correct
71 Correct 1823 ms 5104 KB Output is correct
72 Correct 1928 ms 4936 KB Output is correct
73 Correct 1898 ms 4996 KB Output is correct
74 Correct 1932 ms 5076 KB Output is correct
75 Correct 2001 ms 4920 KB Output is correct
76 Correct 2147 ms 5132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2736 KB Output is correct
2 Correct 8 ms 2812 KB Output is correct
3 Correct 8 ms 2760 KB Output is correct
4 Correct 8 ms 2812 KB Output is correct
5 Correct 8 ms 2776 KB Output is correct
6 Correct 8 ms 2820 KB Output is correct
7 Correct 16 ms 2920 KB Output is correct
8 Correct 22 ms 2940 KB Output is correct
9 Correct 19 ms 2976 KB Output is correct
10 Correct 42 ms 2852 KB Output is correct
11 Correct 22 ms 2844 KB Output is correct
12 Correct 23 ms 2868 KB Output is correct
13 Correct 23 ms 3044 KB Output is correct
14 Correct 39 ms 3280 KB Output is correct
15 Correct 60 ms 3264 KB Output is correct
16 Correct 53 ms 3372 KB Output is correct
17 Correct 95 ms 3400 KB Output is correct
18 Correct 54 ms 3356 KB Output is correct
19 Correct 60 ms 3328 KB Output is correct
20 Correct 85 ms 3356 KB Output is correct
21 Correct 89 ms 3412 KB Output is correct
22 Correct 151 ms 3616 KB Output is correct
23 Correct 137 ms 3592 KB Output is correct
24 Correct 154 ms 3624 KB Output is correct
25 Correct 151 ms 3600 KB Output is correct
26 Correct 143 ms 3720 KB Output is correct
27 Correct 136 ms 3572 KB Output is correct
28 Correct 199 ms 3636 KB Output is correct
29 Correct 235 ms 3712 KB Output is correct
30 Correct 276 ms 3696 KB Output is correct
31 Correct 285 ms 3696 KB Output is correct
32 Correct 254 ms 3704 KB Output is correct
33 Correct 314 ms 3776 KB Output is correct
34 Correct 266 ms 3672 KB Output is correct
35 Correct 259 ms 3708 KB Output is correct
36 Correct 268 ms 3692 KB Output is correct
37 Correct 340 ms 3944 KB Output is correct
38 Correct 444 ms 4132 KB Output is correct
39 Correct 444 ms 4048 KB Output is correct
40 Correct 437 ms 4096 KB Output is correct
41 Correct 448 ms 4232 KB Output is correct
42 Correct 461 ms 4064 KB Output is correct
43 Correct 456 ms 4196 KB Output is correct
44 Correct 475 ms 4180 KB Output is correct
45 Correct 622 ms 4292 KB Output is correct
46 Correct 817 ms 4440 KB Output is correct
47 Correct 788 ms 4284 KB Output is correct
48 Correct 865 ms 4416 KB Output is correct
49 Correct 899 ms 4444 KB Output is correct
50 Correct 915 ms 4480 KB Output is correct
51 Correct 869 ms 4304 KB Output is correct
52 Correct 911 ms 4360 KB Output is correct
53 Correct 888 ms 4504 KB Output is correct
54 Correct 814 ms 4316 KB Output is correct
55 Correct 900 ms 4328 KB Output is correct
56 Correct 910 ms 4380 KB Output is correct
57 Correct 1165 ms 4636 KB Output is correct
58 Correct 1391 ms 4728 KB Output is correct
59 Correct 1226 ms 4800 KB Output is correct
60 Correct 1304 ms 4836 KB Output is correct
61 Correct 1276 ms 4872 KB Output is correct
62 Correct 1209 ms 4788 KB Output is correct
63 Correct 1182 ms 4716 KB Output is correct
64 Correct 1277 ms 4796 KB Output is correct
65 Correct 1236 ms 4756 KB Output is correct
66 Correct 1231 ms 4840 KB Output is correct
67 Correct 1226 ms 4720 KB Output is correct
68 Correct 1234 ms 4868 KB Output is correct
69 Correct 1541 ms 5032 KB Output is correct
70 Correct 1892 ms 5004 KB Output is correct
71 Correct 1823 ms 5104 KB Output is correct
72 Correct 1928 ms 4936 KB Output is correct
73 Correct 1898 ms 4996 KB Output is correct
74 Correct 1932 ms 5076 KB Output is correct
75 Correct 2001 ms 4920 KB Output is correct
76 Correct 2147 ms 5132 KB Output is correct
77 Correct 2251 ms 5012 KB Output is correct
78 Correct 3395 ms 5620 KB Output is correct
79 Correct 3086 ms 5500 KB Output is correct
80 Correct 2602 ms 5504 KB Output is correct
81 Correct 2566 ms 5700 KB Output is correct
82 Correct 2610 ms 5636 KB Output is correct
83 Correct 2824 ms 5484 KB Output is correct
84 Correct 3119 ms 5608 KB Output is correct