Submission #741152

# Submission time Handle Problem Language Result Execution time Memory
741152 2023-05-13T16:17:55 Z rainboy Mountains and Valleys (CCO20_day1problem3) C
25 / 25
1974 ms 111920 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N	500000
#define M	2000000
#define INF	0x3f3f3f3f

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int *ej[N], eo[N], n;
int ii[M], jj[M], ww[M], m;

void append(int i, int j) {
	int o = eo[i]++;

	if (o >= 2 && (o & o - 1) == 0)
		ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);
	ej[i][o] = j;
}

int d_, i_;

void dfs1(int p, int i, int d) {
	int o;

	if (d_ < d)
		d_ = d, i_ = i;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p)
			dfs1(i, j, d + 1);
	}
}

int u, v;

int dfs2(int p, int i) {
	int o, s;

	s = 1;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p)
			s += dfs2(i, j);
	}
	if (s * 3 <= n)
		return s;
	if (u == -1)
		u = i;
	else
		v = i;
	return 0;
}

int rr[N], dd[N], dp1[N], dp2[N], jj1[N][4], jj2[N][4], dq1[N], dq2[N];

void dfs3(int p, int i, int r, int d) {
	int o, g, g_;

	rr[i] = r, dd[i] = d;
	memset(jj1[i], -1, sizeof jj1[i]), memset(jj2[i], -1, sizeof jj2[i]);
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p) {
			dfs3(i, j, r == -1 ? j : r, d + 1);
			for (g = 0; g < 4; g++)
				if (jj1[i][g] == -1 || dp1[jj1[i][g]] < dp1[j]) {
					for (g_ = 3; g_ > g; g_--)
						jj1[i][g_] = jj1[i][g_ - 1];
					jj1[i][g] = j;
					break;
				}
			for (g = 0; g < 4; g++)
				if (jj2[i][g] == -1 || dp2[jj2[i][g]] < dp2[j]) {
					for (g_ = 3; g_ > g; g_--)
						jj2[i][g_] = jj2[i][g_ - 1];
					jj2[i][g] = j;
					break;
				}
		}
	}
	dp1[i] = dp2[i] = 0;
	dp1[i] = max(dp1[i], (jj1[i][0] == -1 ? 0 : dp1[jj1[i][0]] + 1));
	dp2[i] = max(dp2[i], jj2[i][0] == -1 ? 0 : dp2[jj2[i][0]]);
	dp2[i] = max(dp2[i], (jj1[i][0] == -1 ? 0 : dp1[jj1[i][0]] + 1) + (jj1[i][1] == -1 ? 0 : dp1[jj1[i][1]] + 1));
}

void dfs4(int p, int i, int w, int x, int y, int z) {
	int o;

	if (p == -1)
		dq1[i] = dq2[i] = -INF;
	else
		dq1[i] = max(w, dp1[i] - dd[i]), dq2[i] = max(max(x + dp1[i], y) + 2, max(dp2[i], z));
	for (o = eo[i]; o--; ) {
		int j = ej[i][o], j_, j1, j2;

		if (j != p) {
			int w_, x_, y_, z_;

			w_ = w, x_ = x, y_ = y, z_ = z;
			if (p != -1) {
				j_ = j == jj1[i][0] ? jj1[i][1] : jj1[i][0];
				w_ = max(w_, (j_ == -1 ? 0 : dp1[j_] + 1) - dd[i]);
				x_ = max(x_, j_ == -1 ? 0 : dp1[j_] + 1);
				y_ = max(y_, x + (j_ == -1 ? 0 : dp1[j_] + 1));
				j_ = j == jj2[i][0] ? jj2[i][1] : jj2[i][0];
				z_ = max(z_, j_ == -1 ? 0 : dp2[j_]);
				if (j == jj1[i][0])
					j1 = jj1[i][1], j2 = jj1[i][2];
				else if (j == jj1[i][1])
					j1 = jj1[i][0], j2 = jj1[i][2];
				else
					j1 = jj1[i][0], j2 = jj1[i][1];
				z_ = max(z_, (j1 == -1 ? 0 : dp1[j1] + 1) + (j2 == -1 ? 0 : dp1[j2] + 1));
			}
			x_--;
			dfs4(i, j, w_, x_, y_, z_);
		}
	}
}

int ans;

void solve(int s) {
	int g, h, i, j, j1, j2, x;

	dfs3(-1, s, -1, 0);
	dfs4(-1, s, -INF, -INF, -INF, -INF);
	for (h = 0; h < m; h++) {
		i = ii[h], j = jj[h];
		if (ww[h] != 1 && rr[i] != rr[j]) {
			x = max(max(dq2[i], dq2[j]), dq1[i] + dq1[j] + 2);
			j1 = j2 = -1;
			for (g = 0; g < 4; g++)
				if (jj1[s][g] != -1 && jj1[s][g] != rr[i] && jj1[s][g] != rr[j]) {
					if (j1 == -1)
						j1 = jj1[s][g];
					else if (j2 == -1)
						j2 = jj1[s][g];
				}
			x = max(x, max(dq1[i], dq1[j]) + (j1 == -1 ? 0 : dp1[j1] + 1) + 2);
			x = max(x, (j1 == -1 ? 0 : dp1[j1] + 1) + (j2 == -1 ? 0 : dp1[j2] + 1));
			if (jj2[s][0] != rr[i] && jj2[s][0] != rr[j])
				j2 = jj2[s][0];
			else if (jj2[s][1] != rr[i] && jj2[s][1] != rr[j])
				j2 = jj2[s][1];
			else
				j2 = jj2[s][2];
			x = max(x, j2 == -1 ? 0 : dp2[j2]);
			ans = min(ans, (n - 1) * 2 - dd[i] - dd[j] + ww[h] - x);
		}
	}
}

int main() {
	int h, i, j;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		ej[i] = (int *) malloc(2 * sizeof *ej[i]);
	for (h = 0; h < m; h++) {
		scanf("%d%d%d", &i, &j, &ww[h]), ii[h] = i, jj[h] = j;
		if (ww[h] == 1)
			append(i, j), append(j, i);
	}
	d_ = -1, dfs1(-1, 0, 0);
	d_ = -1, dfs1(-1, i_, 0);
	ans = (n - 1) * 2 - d_;
	u = -1, v = -1, dfs2(-1, 0);
	if (u != -1)
		solve(u);
	if (v != -1)
		solve(v);
	printf("%d\n", ans);
	return 0;
}

Compilation message

Main.c: In function 'append':
Main.c:18:23: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   18 |  if (o >= 2 && (o & o - 1) == 0)
      |                     ~~^~~
Main.c: In function 'main':
Main.c:164:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
  164 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
Main.c:168:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
  168 |   scanf("%d%d%d", &i, &j, &ww[h]), ii[h] = i, jj[h] = j;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1364 KB Output is correct
2 Correct 5 ms 1364 KB Output is correct
3 Correct 4 ms 1236 KB Output is correct
4 Correct 4 ms 1108 KB Output is correct
5 Correct 5 ms 1108 KB Output is correct
6 Correct 4 ms 980 KB Output is correct
7 Correct 5 ms 1364 KB Output is correct
8 Correct 5 ms 1236 KB Output is correct
9 Correct 4 ms 1236 KB Output is correct
10 Correct 4 ms 1108 KB Output is correct
11 Correct 5 ms 1236 KB Output is correct
12 Correct 4 ms 1108 KB Output is correct
13 Correct 4 ms 1236 KB Output is correct
14 Correct 4 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 400 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 400 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 1 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 1 ms 468 KB Output is correct
51 Correct 1 ms 468 KB Output is correct
52 Correct 1 ms 468 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 1 ms 468 KB Output is correct
57 Correct 1 ms 468 KB Output is correct
58 Correct 1 ms 468 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 468 KB Output is correct
61 Correct 1 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 4 ms 1364 KB Output is correct
37 Correct 5 ms 1364 KB Output is correct
38 Correct 4 ms 1236 KB Output is correct
39 Correct 4 ms 1108 KB Output is correct
40 Correct 5 ms 1108 KB Output is correct
41 Correct 4 ms 980 KB Output is correct
42 Correct 5 ms 1364 KB Output is correct
43 Correct 5 ms 1236 KB Output is correct
44 Correct 4 ms 1236 KB Output is correct
45 Correct 4 ms 1108 KB Output is correct
46 Correct 5 ms 1236 KB Output is correct
47 Correct 4 ms 1108 KB Output is correct
48 Correct 4 ms 1236 KB Output is correct
49 Correct 4 ms 1236 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 0 ms 400 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 0 ms 340 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 0 ms 340 KB Output is correct
62 Correct 0 ms 340 KB Output is correct
63 Correct 0 ms 340 KB Output is correct
64 Correct 1 ms 468 KB Output is correct
65 Correct 1 ms 468 KB Output is correct
66 Correct 1 ms 468 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 468 KB Output is correct
71 Correct 1 ms 468 KB Output is correct
72 Correct 1 ms 468 KB Output is correct
73 Correct 1 ms 340 KB Output is correct
74 Correct 1 ms 468 KB Output is correct
75 Correct 1 ms 340 KB Output is correct
76 Correct 1 ms 340 KB Output is correct
77 Correct 1 ms 340 KB Output is correct
78 Correct 4 ms 1364 KB Output is correct
79 Correct 5 ms 1268 KB Output is correct
80 Correct 4 ms 1236 KB Output is correct
81 Correct 4 ms 1084 KB Output is correct
82 Correct 5 ms 1028 KB Output is correct
83 Correct 3 ms 980 KB Output is correct
84 Correct 5 ms 1364 KB Output is correct
85 Correct 4 ms 1236 KB Output is correct
86 Correct 4 ms 1236 KB Output is correct
87 Correct 4 ms 1108 KB Output is correct
88 Correct 5 ms 1236 KB Output is correct
89 Correct 5 ms 1108 KB Output is correct
90 Correct 3 ms 1108 KB Output is correct
91 Correct 4 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 4 ms 1364 KB Output is correct
37 Correct 5 ms 1364 KB Output is correct
38 Correct 4 ms 1236 KB Output is correct
39 Correct 4 ms 1108 KB Output is correct
40 Correct 5 ms 1108 KB Output is correct
41 Correct 4 ms 980 KB Output is correct
42 Correct 5 ms 1364 KB Output is correct
43 Correct 5 ms 1236 KB Output is correct
44 Correct 4 ms 1236 KB Output is correct
45 Correct 4 ms 1108 KB Output is correct
46 Correct 5 ms 1236 KB Output is correct
47 Correct 4 ms 1108 KB Output is correct
48 Correct 4 ms 1236 KB Output is correct
49 Correct 4 ms 1236 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 0 ms 400 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 0 ms 340 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 0 ms 340 KB Output is correct
62 Correct 0 ms 340 KB Output is correct
63 Correct 0 ms 340 KB Output is correct
64 Correct 1 ms 468 KB Output is correct
65 Correct 1 ms 468 KB Output is correct
66 Correct 1 ms 468 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 468 KB Output is correct
71 Correct 1 ms 468 KB Output is correct
72 Correct 1 ms 468 KB Output is correct
73 Correct 1 ms 340 KB Output is correct
74 Correct 1 ms 468 KB Output is correct
75 Correct 1 ms 340 KB Output is correct
76 Correct 1 ms 340 KB Output is correct
77 Correct 1 ms 340 KB Output is correct
78 Correct 4 ms 1364 KB Output is correct
79 Correct 5 ms 1268 KB Output is correct
80 Correct 4 ms 1236 KB Output is correct
81 Correct 4 ms 1084 KB Output is correct
82 Correct 5 ms 1028 KB Output is correct
83 Correct 3 ms 980 KB Output is correct
84 Correct 5 ms 1364 KB Output is correct
85 Correct 4 ms 1236 KB Output is correct
86 Correct 4 ms 1236 KB Output is correct
87 Correct 4 ms 1108 KB Output is correct
88 Correct 5 ms 1236 KB Output is correct
89 Correct 5 ms 1108 KB Output is correct
90 Correct 3 ms 1108 KB Output is correct
91 Correct 4 ms 1108 KB Output is correct
92 Correct 140 ms 13108 KB Output is correct
93 Correct 138 ms 14232 KB Output is correct
94 Correct 82 ms 13112 KB Output is correct
95 Correct 86 ms 12360 KB Output is correct
96 Correct 131 ms 12464 KB Output is correct
97 Correct 111 ms 16320 KB Output is correct
98 Correct 115 ms 16248 KB Output is correct
99 Correct 87 ms 14152 KB Output is correct
100 Correct 82 ms 13196 KB Output is correct
101 Correct 107 ms 12468 KB Output is correct
102 Correct 66 ms 10488 KB Output is correct
103 Correct 135 ms 16348 KB Output is correct
104 Correct 149 ms 14004 KB Output is correct
105 Correct 117 ms 15544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 372 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 0 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 0 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 0 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 0 ms 340 KB Output is correct
33 Correct 0 ms 340 KB Output is correct
34 Correct 0 ms 340 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 4 ms 1364 KB Output is correct
37 Correct 5 ms 1364 KB Output is correct
38 Correct 4 ms 1236 KB Output is correct
39 Correct 4 ms 1108 KB Output is correct
40 Correct 5 ms 1108 KB Output is correct
41 Correct 4 ms 980 KB Output is correct
42 Correct 5 ms 1364 KB Output is correct
43 Correct 5 ms 1236 KB Output is correct
44 Correct 4 ms 1236 KB Output is correct
45 Correct 4 ms 1108 KB Output is correct
46 Correct 5 ms 1236 KB Output is correct
47 Correct 4 ms 1108 KB Output is correct
48 Correct 4 ms 1236 KB Output is correct
49 Correct 4 ms 1236 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 1 ms 340 KB Output is correct
52 Correct 0 ms 400 KB Output is correct
53 Correct 0 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 0 ms 340 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 0 ms 340 KB Output is correct
62 Correct 0 ms 340 KB Output is correct
63 Correct 0 ms 340 KB Output is correct
64 Correct 1 ms 468 KB Output is correct
65 Correct 1 ms 468 KB Output is correct
66 Correct 1 ms 468 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 468 KB Output is correct
71 Correct 1 ms 468 KB Output is correct
72 Correct 1 ms 468 KB Output is correct
73 Correct 1 ms 340 KB Output is correct
74 Correct 1 ms 468 KB Output is correct
75 Correct 1 ms 340 KB Output is correct
76 Correct 1 ms 340 KB Output is correct
77 Correct 1 ms 340 KB Output is correct
78 Correct 4 ms 1364 KB Output is correct
79 Correct 5 ms 1268 KB Output is correct
80 Correct 4 ms 1236 KB Output is correct
81 Correct 4 ms 1084 KB Output is correct
82 Correct 5 ms 1028 KB Output is correct
83 Correct 3 ms 980 KB Output is correct
84 Correct 5 ms 1364 KB Output is correct
85 Correct 4 ms 1236 KB Output is correct
86 Correct 4 ms 1236 KB Output is correct
87 Correct 4 ms 1108 KB Output is correct
88 Correct 5 ms 1236 KB Output is correct
89 Correct 5 ms 1108 KB Output is correct
90 Correct 3 ms 1108 KB Output is correct
91 Correct 4 ms 1108 KB Output is correct
92 Correct 140 ms 13108 KB Output is correct
93 Correct 138 ms 14232 KB Output is correct
94 Correct 82 ms 13112 KB Output is correct
95 Correct 86 ms 12360 KB Output is correct
96 Correct 131 ms 12464 KB Output is correct
97 Correct 111 ms 16320 KB Output is correct
98 Correct 115 ms 16248 KB Output is correct
99 Correct 87 ms 14152 KB Output is correct
100 Correct 82 ms 13196 KB Output is correct
101 Correct 107 ms 12468 KB Output is correct
102 Correct 66 ms 10488 KB Output is correct
103 Correct 135 ms 16348 KB Output is correct
104 Correct 149 ms 14004 KB Output is correct
105 Correct 117 ms 15544 KB Output is correct
106 Correct 1811 ms 111900 KB Output is correct
107 Correct 1786 ms 111864 KB Output is correct
108 Correct 1468 ms 98716 KB Output is correct
109 Correct 1434 ms 92236 KB Output is correct
110 Correct 1457 ms 88312 KB Output is correct
111 Correct 912 ms 74696 KB Output is correct
112 Correct 1753 ms 111920 KB Output is correct
113 Correct 1766 ms 97744 KB Output is correct
114 Correct 1818 ms 107368 KB Output is correct
115 Correct 1974 ms 92232 KB Output is correct
116 Correct 1803 ms 98888 KB Output is correct
117 Correct 1374 ms 92160 KB Output is correct
118 Correct 1265 ms 75616 KB Output is correct
119 Correct 1297 ms 75684 KB Output is correct