Submission #501274

# Submission time Handle Problem Language Result Execution time Memory
501274 2022-01-02T17:34:46 Z rainboy Wells (CEOI21_wells) C
100 / 100
7297 ms 406948 KB
#include <stdio.h>

#define N	1500000
#define INF	0x3f3f3f3f3f3f3f3fLL
#define MD	1000000007
#define H_	22	/* H_ = ceil(log2(N * 2)) */
#define N_	(1 << H_)

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

int mem[(N - 1) * 2], *ptr = mem, *ej[N], eo[N], n, k;

int ll[N], jj[N], ta[N], tb[N], kk[N + 1], qu[N * 2];

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

	kk[d + 1]++;
	ll[i] = 0, jj[i] = -1;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p) {
			dfs1(i, j, d + 1);
			if (ll[i] < ll[j])
				ll[i] = ll[j], jj[i] = j;
		}
	}
	ll[i]++;
}

void dfs2(int p, int i, int d) {
	static int time;
	int o;

	qu[ta[i] = time++] = i, tb[i] = kk[d]++;
	if (jj[i] != -1)
		dfs2(i, jj[i], d + 1);
	else
		time++;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p && j != jj[i])
			dfs2(i, j, d + 1);
	}
}

int cnt[N * 2]; long long xx[N + 1];

void get_range(int a, int *l, int *r) {
	*l = tb[qu[a]], *r = *l + cnt[a];
}

void dfs3(int p, int i) {
	int o, d, l1, r1, l2, r2;
	long long c;

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

		if (j != p)
			dfs3(i, j);
	}
	if (k <= ll[i]) {
		get_range(ta[i] + k - 1, &l1, &r1);
		xx[l1]++, xx[r1]--;
		if (p != -1)
			xx[tb[p]] -= r1 - l1, xx[tb[p] + 1] += r1 - l1;
	}
	cnt[ta[i]]++;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p && j != jj[i]) {
			for (d = 1; d <= ll[j] && d < k; d++)
				if (k - d <= ll[i]) {
					get_range(ta[i] + k - d - 1, &l1, &r1), get_range(ta[j] + d - 1, &l2, &r2);
					c = (long long) (r1 - l1) * (r2 - l2);
					xx[l1] += r2 - l2, xx[r1] -= r2 - l2;
					xx[l2] += r1 - l1, xx[r2] -= r1 - l1;
					xx[tb[i]] -= c, xx[tb[i] + 1] += c;
					if (p != -1)
						xx[tb[p]] -= c, xx[tb[p] + 1] += c;
				}
			for (d = 1; d <= ll[j]; d++)
				cnt[ta[i] + d] += cnt[ta[j] + d - 1];
		}
	}
}

long long ww[N];

void dfs4(int p, int i) {
	int o;

	ww[i] = xx[tb[i]];
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p) {
			dfs4(i, j);
			ww[i] += ww[j];
		}
	}
}

int h_, n_;
long long stu[N_ * 2], lzu[N_]; int stv[N_ * 2], lzv[N_];

void put(int i, long long u, long long v) {
	if (stu[i] != INF && u != INF)
		stu[i] += u, stv[i] = (long long) stv[i] * v % MD;
	else
		stu[i] = INF, stv[i] = 0;
	if (i < n_) {
		if (lzu[i] != INF && u != INF)
			lzu[i] += u, lzv[i] = (long long) lzv[i] * v % MD;
		else
			lzu[i] = INF, lzv[i] = 0;
	}
}

void pus(int i) {
	if (lzu[i] != 0 || lzv[i] != 1)
		put(i << 1 | 0, lzu[i], lzv[i]), put(i << 1 | 1, lzu[i], lzv[i]), lzu[i] = 0, lzv[i] = 1;
}

void pul(int i) {
	if (lzu[i] == 0 && lzv[i] == 1) {
		int l = i << 1, r = l | 1;

		if (stu[l] < stu[r])
			stu[i] = stu[l], stv[i] = stv[l];
		else if (stu[l] > stu[r])
			stu[i] = stu[r], stv[i] = stv[r];
		else
			stu[i] = stu[l], stv[i] = (stv[l] + stv[r]) % MD;
	}
}

void push(int i) {
	int h;

	for (h = h_; h > 0; h--)
		pus(i >> h);
}

void pull(int i) {
	while (i > 1)
		pul(i >>= 1);
}

void upd(int i, long long u, int v) {
	push(i += n_);
	stu[i] = u, stv[i] = v;
	pull(i);
}

void update(int l, int r, long long u, int v) {
	if (l <= r) {
		int l_ = l += n_, r_ = r += n_;

		push(l_), push(r_);
		for ( ; l <= r; l >>= 1, r >>= 1) {
			if ((l & 1) == 1)
				put(l++, u, v);
			if ((r & 1) == 0)
				put(r--, u, v);
		}
		pull(l_), pull(r_);
	}
}

void query(int l, int r, long long *u_, int *v_) {
	long long u = INF, v = 0;

	if (l <= r) {
		push(l += n_), push(r += n_);
		for ( ; l <= r; l >>= 1, r >>= 1) {
			if ((l & 1) == 1) {
				if (u > stu[l])
					u = stu[l], v = 0;
				if (u == stu[l])
					v = (v + stv[l]) % MD;
				l++;
			}
			if ((r & 1) == 0) {
				if (u > stu[r])
					u = stu[r], v = 0;
				if (u == stu[r])
					v = (v + stv[r]) % MD;
				r--;
			}
		}
	}
	*u_ = u, *v_ = v;
}

void process(int i, int j, int d) {
	long long u1, ui, uj, u;
	int v1, vi, vj, v;

	u1 = INF, v1 = 0;
	query(ta[i] + d, ta[i] + d, &ui, &vi);
	query(ta[j], ta[j] + min(ll[j], min(k - d - 1, d - 2)), &uj, &vj);
	u = ui + uj;
	v = (long long) vi * vj % MD;
	if (u1 > u)
		u1 = u, v1 = 0;
	if (u1 == u)
		v1 = (v1 + v) % MD;
	if (d - 1 <= ll[j]) {
		query(ta[j] + d - 1, ta[j] + d - 1, &uj, &vj);
		query(ta[i] + 1, ta[i] + min(k - d, d), &ui, &vi);
		u = ui + uj;
		v = (long long) vi * vj % MD;
		if (u1 > u)
			u1 = u, v1 = 0;
		if (u1 == u)
			v1 = (v1 + v) % MD;
	}
	upd(ta[i] + d, u1, v1);
}

void dfs5(int p, int i) {
	int o, j, d;
	long long u;
	int v;

	upd(ta[i] + 0, ww[i], 1);
	if (jj[i] == -1)
		upd(ta[i] + 1, 0, 1);
	else {
		for (o = eo[i]; o--; ) {
			j = ej[i][o];
			if (j != p)
				dfs5(i, j);
		}
		j = jj[i];
		query(ta[j], ta[j] + ll[j], &u, &v);
		update(ta[i] + 0, ta[i] + 0, u, v);
		if (ll[i] >= k)
			upd(ta[i] + k, INF, 0);
		for (o = eo[i]; o--; ) {
			j = ej[i][o];
			if (j != p && j != jj[i]) {
				int lower, upper;

				query(ta[j], ta[j] + ll[j], &u, &v);
				update(ta[i] + 0, ta[i] + 0, u, v);
				lower = ll[j] + 2, upper = min(ll[i], k - 1 - ll[j]);
				if (lower > upper)
					for (d = min(ll[i], k); d > 0; d--)
						process(i, j, d);
				else {
					for (d = min(ll[i], k); d > upper; d--)
						process(i, j, d);
					query(ta[j], ta[j] + ll[j], &u, &v);
					update(ta[i] + lower, ta[i] + upper, u, v);
					for (d = lower - 1; d > 0; d--)
						process(i, j, d);
				}
			}
		}
	}
}

int main() {
	static int ii_[N - 1], jj_[N - 1];
	int h, i, j, d, v;
	long long w, u;

	scanf("%d%d", &n, &k);
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		ii_[h] = i, jj_[h] = j;
		eo[i]++, eo[j]++;
	}
	for (i = 0; i < n; i++) {
		ej[i] = ptr, ptr += eo[i];
		eo[i] = 0;
	}
	for (h = 0; h < n - 1; h++) {
		i = ii_[h], j = jj_[h];
		ej[i][eo[i]++] = j, ej[j][eo[j]++] = i;
	}
	dfs1(-1, 0, 0);
	for (d = 1; d <= n; d++)
		kk[d] += kk[d - 1];
	dfs2(-1, 0, 0);
	dfs3(-1, 0);
	for (i = 1; i <= n; i++)
		xx[i] += xx[i - 1];
	dfs4(-1, 0);
	w = 0;
	for (i = 0; i < n; i++)
		w += ww[i];
	w /= k;
	h_ = 0;
	while (1 << h_ < n * 2)
		h_++;
	n_ = 1 << h_;
	for (i = 0; i < n_; i++)
		lzv[i] = 1;
	dfs5(-1, 0);
	query(ta[0], ta[0] + ll[0], &u, &v);
	if (u == w)
		printf("YES\n%d\n", v);
	else
		printf("NO\n0\n");
	return 0;
}

Compilation message

wells.c: In function 'main':
wells.c:275:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
  275 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
wells.c:277:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
  277 |   scanf("%d%d", &i, &j), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 436 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 412 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 408 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 0 ms 408 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 0 ms 416 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 412 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 412 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 412 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 436 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 412 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 436 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 412 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 408 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 0 ms 408 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 0 ms 416 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 412 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 412 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 412 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 436 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 412 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 0 ms 332 KB Output is correct
60 Correct 5 ms 972 KB Output is correct
61 Correct 3 ms 716 KB Output is correct
62 Correct 7 ms 936 KB Output is correct
63 Correct 21 ms 1868 KB Output is correct
64 Correct 16 ms 2580 KB Output is correct
65 Correct 16 ms 1612 KB Output is correct
66 Correct 23 ms 1764 KB Output is correct
67 Correct 17 ms 2684 KB Output is correct
68 Correct 7 ms 972 KB Output is correct
69 Correct 9 ms 932 KB Output is correct
70 Correct 22 ms 1968 KB Output is correct
71 Correct 8 ms 1196 KB Output is correct
72 Correct 10 ms 1228 KB Output is correct
73 Correct 9 ms 1332 KB Output is correct
74 Correct 13 ms 2036 KB Output is correct
75 Correct 24 ms 1944 KB Output is correct
76 Correct 28 ms 2032 KB Output is correct
77 Correct 10 ms 1228 KB Output is correct
78 Correct 12 ms 1228 KB Output is correct
79 Correct 10 ms 1136 KB Output is correct
80 Correct 11 ms 1740 KB Output is correct
81 Correct 12 ms 1848 KB Output is correct
82 Correct 22 ms 1868 KB Output is correct
83 Correct 24 ms 2096 KB Output is correct
84 Correct 23 ms 1868 KB Output is correct
85 Correct 16 ms 2244 KB Output is correct
86 Correct 25 ms 1900 KB Output is correct
87 Correct 16 ms 1868 KB Output is correct
88 Correct 15 ms 1804 KB Output is correct
89 Correct 16 ms 1588 KB Output is correct
90 Correct 11 ms 1084 KB Output is correct
91 Correct 18 ms 1948 KB Output is correct
92 Correct 20 ms 2224 KB Output is correct
93 Correct 18 ms 2124 KB Output is correct
94 Correct 21 ms 1792 KB Output is correct
95 Correct 17 ms 1728 KB Output is correct
96 Correct 10 ms 1164 KB Output is correct
97 Correct 8 ms 1256 KB Output is correct
98 Correct 8 ms 1356 KB Output is correct
99 Correct 13 ms 1420 KB Output is correct
100 Correct 20 ms 2068 KB Output is correct
101 Correct 22 ms 1848 KB Output is correct
102 Correct 21 ms 2132 KB Output is correct
103 Correct 24 ms 2124 KB Output is correct
104 Correct 17 ms 1972 KB Output is correct
105 Correct 15 ms 1996 KB Output is correct
106 Correct 22 ms 1536 KB Output is correct
107 Correct 14 ms 1980 KB Output is correct
108 Correct 16 ms 1644 KB Output is correct
109 Correct 14 ms 1700 KB Output is correct
110 Correct 22 ms 2000 KB Output is correct
111 Correct 19 ms 1996 KB Output is correct
112 Correct 18 ms 2124 KB Output is correct
113 Correct 20 ms 1984 KB Output is correct
114 Correct 20 ms 2124 KB Output is correct
115 Correct 23 ms 1932 KB Output is correct
116 Correct 18 ms 2204 KB Output is correct
117 Correct 23 ms 2000 KB Output is correct
118 Correct 18 ms 2340 KB Output is correct
119 Correct 20 ms 1976 KB Output is correct
120 Correct 23 ms 2088 KB Output is correct
121 Correct 27 ms 2124 KB Output is correct
122 Correct 27 ms 2184 KB Output is correct
123 Correct 21 ms 1996 KB Output is correct
124 Correct 22 ms 2084 KB Output is correct
125 Correct 26 ms 1996 KB Output is correct
126 Correct 24 ms 1920 KB Output is correct
127 Correct 18 ms 2288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 436 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 412 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 408 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 0 ms 408 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 0 ms 416 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 412 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 412 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 412 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 436 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 412 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 0 ms 332 KB Output is correct
60 Correct 5 ms 972 KB Output is correct
61 Correct 3 ms 716 KB Output is correct
62 Correct 7 ms 936 KB Output is correct
63 Correct 21 ms 1868 KB Output is correct
64 Correct 16 ms 2580 KB Output is correct
65 Correct 16 ms 1612 KB Output is correct
66 Correct 23 ms 1764 KB Output is correct
67 Correct 17 ms 2684 KB Output is correct
68 Correct 7 ms 972 KB Output is correct
69 Correct 9 ms 932 KB Output is correct
70 Correct 22 ms 1968 KB Output is correct
71 Correct 8 ms 1196 KB Output is correct
72 Correct 10 ms 1228 KB Output is correct
73 Correct 9 ms 1332 KB Output is correct
74 Correct 13 ms 2036 KB Output is correct
75 Correct 24 ms 1944 KB Output is correct
76 Correct 28 ms 2032 KB Output is correct
77 Correct 10 ms 1228 KB Output is correct
78 Correct 12 ms 1228 KB Output is correct
79 Correct 10 ms 1136 KB Output is correct
80 Correct 11 ms 1740 KB Output is correct
81 Correct 12 ms 1848 KB Output is correct
82 Correct 22 ms 1868 KB Output is correct
83 Correct 24 ms 2096 KB Output is correct
84 Correct 23 ms 1868 KB Output is correct
85 Correct 16 ms 2244 KB Output is correct
86 Correct 25 ms 1900 KB Output is correct
87 Correct 16 ms 1868 KB Output is correct
88 Correct 15 ms 1804 KB Output is correct
89 Correct 16 ms 1588 KB Output is correct
90 Correct 11 ms 1084 KB Output is correct
91 Correct 18 ms 1948 KB Output is correct
92 Correct 20 ms 2224 KB Output is correct
93 Correct 18 ms 2124 KB Output is correct
94 Correct 21 ms 1792 KB Output is correct
95 Correct 17 ms 1728 KB Output is correct
96 Correct 10 ms 1164 KB Output is correct
97 Correct 8 ms 1256 KB Output is correct
98 Correct 8 ms 1356 KB Output is correct
99 Correct 13 ms 1420 KB Output is correct
100 Correct 20 ms 2068 KB Output is correct
101 Correct 22 ms 1848 KB Output is correct
102 Correct 21 ms 2132 KB Output is correct
103 Correct 24 ms 2124 KB Output is correct
104 Correct 17 ms 1972 KB Output is correct
105 Correct 15 ms 1996 KB Output is correct
106 Correct 22 ms 1536 KB Output is correct
107 Correct 14 ms 1980 KB Output is correct
108 Correct 16 ms 1644 KB Output is correct
109 Correct 14 ms 1700 KB Output is correct
110 Correct 22 ms 2000 KB Output is correct
111 Correct 19 ms 1996 KB Output is correct
112 Correct 18 ms 2124 KB Output is correct
113 Correct 20 ms 1984 KB Output is correct
114 Correct 20 ms 2124 KB Output is correct
115 Correct 23 ms 1932 KB Output is correct
116 Correct 18 ms 2204 KB Output is correct
117 Correct 23 ms 2000 KB Output is correct
118 Correct 18 ms 2340 KB Output is correct
119 Correct 20 ms 1976 KB Output is correct
120 Correct 23 ms 2088 KB Output is correct
121 Correct 27 ms 2124 KB Output is correct
122 Correct 27 ms 2184 KB Output is correct
123 Correct 21 ms 1996 KB Output is correct
124 Correct 22 ms 2084 KB Output is correct
125 Correct 26 ms 1996 KB Output is correct
126 Correct 24 ms 1920 KB Output is correct
127 Correct 18 ms 2288 KB Output is correct
128 Correct 0 ms 332 KB Output is correct
129 Correct 544 ms 26040 KB Output is correct
130 Correct 427 ms 41544 KB Output is correct
131 Correct 437 ms 37824 KB Output is correct
132 Correct 518 ms 25240 KB Output is correct
133 Correct 478 ms 29380 KB Output is correct
134 Correct 535 ms 34728 KB Output is correct
135 Correct 488 ms 21788 KB Output is correct
136 Correct 443 ms 28464 KB Output is correct
137 Correct 602 ms 30868 KB Output is correct
138 Correct 597 ms 39064 KB Output is correct
139 Correct 1829 ms 80920 KB Output is correct
140 Correct 1654 ms 81788 KB Output is correct
141 Correct 1889 ms 71676 KB Output is correct
142 Correct 1591 ms 76172 KB Output is correct
143 Correct 1610 ms 75180 KB Output is correct
144 Correct 1709 ms 68712 KB Output is correct
145 Correct 1563 ms 94972 KB Output is correct
146 Correct 2328 ms 82808 KB Output is correct
147 Correct 1824 ms 87448 KB Output is correct
148 Correct 1513 ms 52596 KB Output is correct
149 Correct 579 ms 25920 KB Output is correct
150 Correct 531 ms 24952 KB Output is correct
151 Correct 547 ms 27908 KB Output is correct
152 Correct 496 ms 23316 KB Output is correct
153 Correct 518 ms 23204 KB Output is correct
154 Correct 487 ms 22456 KB Output is correct
155 Correct 496 ms 28364 KB Output is correct
156 Correct 597 ms 36172 KB Output is correct
157 Correct 618 ms 29640 KB Output is correct
158 Correct 695 ms 34108 KB Output is correct
159 Correct 706 ms 40984 KB Output is correct
160 Correct 1672 ms 63012 KB Output is correct
161 Correct 1888 ms 77992 KB Output is correct
162 Correct 1763 ms 82876 KB Output is correct
163 Correct 1666 ms 85456 KB Output is correct
164 Correct 1643 ms 99348 KB Output is correct
165 Correct 2079 ms 71732 KB Output is correct
166 Correct 1747 ms 72988 KB Output is correct
167 Correct 1513 ms 90608 KB Output is correct
168 Correct 2149 ms 79440 KB Output is correct
169 Correct 2426 ms 80556 KB Output is correct
170 Correct 2652 ms 75180 KB Output is correct
171 Correct 1520 ms 53412 KB Output is correct
172 Correct 1534 ms 56284 KB Output is correct
173 Correct 1760 ms 77348 KB Output is correct
174 Correct 1776 ms 82988 KB Output is correct
175 Correct 1773 ms 73752 KB Output is correct
176 Correct 1778 ms 71876 KB Output is correct
177 Correct 1810 ms 75016 KB Output is correct
178 Correct 1656 ms 89776 KB Output is correct
179 Correct 1945 ms 84680 KB Output is correct
180 Correct 1869 ms 88344 KB Output is correct
181 Correct 1385 ms 58144 KB Output is correct
182 Correct 1772 ms 77648 KB Output is correct
183 Correct 1714 ms 81716 KB Output is correct
184 Correct 1599 ms 70116 KB Output is correct
185 Correct 1701 ms 69920 KB Output is correct
186 Correct 1456 ms 63252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 436 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 412 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 408 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 324 KB Output is correct
26 Correct 0 ms 408 KB Output is correct
27 Correct 0 ms 332 KB Output is correct
28 Correct 0 ms 416 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 0 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 412 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 412 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 412 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 436 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 412 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 0 ms 332 KB Output is correct
60 Correct 5 ms 972 KB Output is correct
61 Correct 3 ms 716 KB Output is correct
62 Correct 7 ms 936 KB Output is correct
63 Correct 21 ms 1868 KB Output is correct
64 Correct 16 ms 2580 KB Output is correct
65 Correct 16 ms 1612 KB Output is correct
66 Correct 23 ms 1764 KB Output is correct
67 Correct 17 ms 2684 KB Output is correct
68 Correct 7 ms 972 KB Output is correct
69 Correct 9 ms 932 KB Output is correct
70 Correct 22 ms 1968 KB Output is correct
71 Correct 8 ms 1196 KB Output is correct
72 Correct 10 ms 1228 KB Output is correct
73 Correct 9 ms 1332 KB Output is correct
74 Correct 13 ms 2036 KB Output is correct
75 Correct 24 ms 1944 KB Output is correct
76 Correct 28 ms 2032 KB Output is correct
77 Correct 10 ms 1228 KB Output is correct
78 Correct 12 ms 1228 KB Output is correct
79 Correct 10 ms 1136 KB Output is correct
80 Correct 11 ms 1740 KB Output is correct
81 Correct 12 ms 1848 KB Output is correct
82 Correct 22 ms 1868 KB Output is correct
83 Correct 24 ms 2096 KB Output is correct
84 Correct 23 ms 1868 KB Output is correct
85 Correct 16 ms 2244 KB Output is correct
86 Correct 25 ms 1900 KB Output is correct
87 Correct 16 ms 1868 KB Output is correct
88 Correct 15 ms 1804 KB Output is correct
89 Correct 16 ms 1588 KB Output is correct
90 Correct 11 ms 1084 KB Output is correct
91 Correct 18 ms 1948 KB Output is correct
92 Correct 20 ms 2224 KB Output is correct
93 Correct 18 ms 2124 KB Output is correct
94 Correct 21 ms 1792 KB Output is correct
95 Correct 17 ms 1728 KB Output is correct
96 Correct 10 ms 1164 KB Output is correct
97 Correct 8 ms 1256 KB Output is correct
98 Correct 8 ms 1356 KB Output is correct
99 Correct 13 ms 1420 KB Output is correct
100 Correct 20 ms 2068 KB Output is correct
101 Correct 22 ms 1848 KB Output is correct
102 Correct 21 ms 2132 KB Output is correct
103 Correct 24 ms 2124 KB Output is correct
104 Correct 17 ms 1972 KB Output is correct
105 Correct 15 ms 1996 KB Output is correct
106 Correct 22 ms 1536 KB Output is correct
107 Correct 14 ms 1980 KB Output is correct
108 Correct 16 ms 1644 KB Output is correct
109 Correct 14 ms 1700 KB Output is correct
110 Correct 22 ms 2000 KB Output is correct
111 Correct 19 ms 1996 KB Output is correct
112 Correct 18 ms 2124 KB Output is correct
113 Correct 20 ms 1984 KB Output is correct
114 Correct 20 ms 2124 KB Output is correct
115 Correct 23 ms 1932 KB Output is correct
116 Correct 18 ms 2204 KB Output is correct
117 Correct 23 ms 2000 KB Output is correct
118 Correct 18 ms 2340 KB Output is correct
119 Correct 20 ms 1976 KB Output is correct
120 Correct 23 ms 2088 KB Output is correct
121 Correct 27 ms 2124 KB Output is correct
122 Correct 27 ms 2184 KB Output is correct
123 Correct 21 ms 1996 KB Output is correct
124 Correct 22 ms 2084 KB Output is correct
125 Correct 26 ms 1996 KB Output is correct
126 Correct 24 ms 1920 KB Output is correct
127 Correct 18 ms 2288 KB Output is correct
128 Correct 0 ms 332 KB Output is correct
129 Correct 544 ms 26040 KB Output is correct
130 Correct 427 ms 41544 KB Output is correct
131 Correct 437 ms 37824 KB Output is correct
132 Correct 518 ms 25240 KB Output is correct
133 Correct 478 ms 29380 KB Output is correct
134 Correct 535 ms 34728 KB Output is correct
135 Correct 488 ms 21788 KB Output is correct
136 Correct 443 ms 28464 KB Output is correct
137 Correct 602 ms 30868 KB Output is correct
138 Correct 597 ms 39064 KB Output is correct
139 Correct 1829 ms 80920 KB Output is correct
140 Correct 1654 ms 81788 KB Output is correct
141 Correct 1889 ms 71676 KB Output is correct
142 Correct 1591 ms 76172 KB Output is correct
143 Correct 1610 ms 75180 KB Output is correct
144 Correct 1709 ms 68712 KB Output is correct
145 Correct 1563 ms 94972 KB Output is correct
146 Correct 2328 ms 82808 KB Output is correct
147 Correct 1824 ms 87448 KB Output is correct
148 Correct 1513 ms 52596 KB Output is correct
149 Correct 579 ms 25920 KB Output is correct
150 Correct 531 ms 24952 KB Output is correct
151 Correct 547 ms 27908 KB Output is correct
152 Correct 496 ms 23316 KB Output is correct
153 Correct 518 ms 23204 KB Output is correct
154 Correct 487 ms 22456 KB Output is correct
155 Correct 496 ms 28364 KB Output is correct
156 Correct 597 ms 36172 KB Output is correct
157 Correct 618 ms 29640 KB Output is correct
158 Correct 695 ms 34108 KB Output is correct
159 Correct 706 ms 40984 KB Output is correct
160 Correct 1672 ms 63012 KB Output is correct
161 Correct 1888 ms 77992 KB Output is correct
162 Correct 1763 ms 82876 KB Output is correct
163 Correct 1666 ms 85456 KB Output is correct
164 Correct 1643 ms 99348 KB Output is correct
165 Correct 2079 ms 71732 KB Output is correct
166 Correct 1747 ms 72988 KB Output is correct
167 Correct 1513 ms 90608 KB Output is correct
168 Correct 2149 ms 79440 KB Output is correct
169 Correct 2426 ms 80556 KB Output is correct
170 Correct 2652 ms 75180 KB Output is correct
171 Correct 1520 ms 53412 KB Output is correct
172 Correct 1534 ms 56284 KB Output is correct
173 Correct 1760 ms 77348 KB Output is correct
174 Correct 1776 ms 82988 KB Output is correct
175 Correct 1773 ms 73752 KB Output is correct
176 Correct 1778 ms 71876 KB Output is correct
177 Correct 1810 ms 75016 KB Output is correct
178 Correct 1656 ms 89776 KB Output is correct
179 Correct 1945 ms 84680 KB Output is correct
180 Correct 1869 ms 88344 KB Output is correct
181 Correct 1385 ms 58144 KB Output is correct
182 Correct 1772 ms 77648 KB Output is correct
183 Correct 1714 ms 81716 KB Output is correct
184 Correct 1599 ms 70116 KB Output is correct
185 Correct 1701 ms 69920 KB Output is correct
186 Correct 1456 ms 63252 KB Output is correct
187 Correct 6123 ms 229852 KB Output is correct
188 Correct 6196 ms 232296 KB Output is correct
189 Correct 5865 ms 252792 KB Output is correct
190 Correct 6064 ms 233552 KB Output is correct
191 Correct 6114 ms 230444 KB Output is correct
192 Correct 6260 ms 239712 KB Output is correct
193 Correct 6872 ms 273552 KB Output is correct
194 Correct 7237 ms 268712 KB Output is correct
195 Correct 7297 ms 235164 KB Output is correct
196 Correct 6781 ms 216340 KB Output is correct
197 Correct 6099 ms 205120 KB Output is correct
198 Correct 6679 ms 217340 KB Output is correct
199 Correct 6526 ms 212712 KB Output is correct
200 Correct 6487 ms 219368 KB Output is correct
201 Correct 6471 ms 214044 KB Output is correct
202 Correct 6203 ms 182592 KB Output is correct
203 Correct 6696 ms 254160 KB Output is correct
204 Correct 6052 ms 182760 KB Output is correct
205 Correct 6155 ms 183320 KB Output is correct
206 Correct 6232 ms 181916 KB Output is correct
207 Correct 6169 ms 183844 KB Output is correct
208 Correct 6773 ms 211872 KB Output is correct
209 Correct 6247 ms 213508 KB Output is correct
210 Correct 6172 ms 222816 KB Output is correct
211 Correct 6176 ms 238884 KB Output is correct
212 Correct 6339 ms 194176 KB Output is correct
213 Correct 5839 ms 214236 KB Output is correct
214 Correct 5581 ms 292968 KB Output is correct
215 Correct 5586 ms 339036 KB Output is correct
216 Correct 5501 ms 273744 KB Output is correct
217 Correct 5254 ms 182164 KB Output is correct
218 Correct 5761 ms 178724 KB Output is correct
219 Correct 6653 ms 251888 KB Output is correct
220 Correct 6133 ms 259484 KB Output is correct
221 Correct 6453 ms 227640 KB Output is correct
222 Correct 6040 ms 224564 KB Output is correct
223 Correct 5545 ms 268676 KB Output is correct
224 Correct 5529 ms 232720 KB Output is correct
225 Correct 6753 ms 270848 KB Output is correct
226 Correct 4975 ms 406948 KB Output is correct
227 Correct 5598 ms 177764 KB Output is correct
228 Correct 5517 ms 177732 KB Output is correct
229 Correct 6096 ms 229372 KB Output is correct
230 Correct 5976 ms 229464 KB Output is correct
231 Correct 5989 ms 221148 KB Output is correct
232 Correct 5558 ms 232940 KB Output is correct
233 Correct 5917 ms 292432 KB Output is correct
234 Correct 6318 ms 236092 KB Output is correct
235 Correct 5924 ms 268056 KB Output is correct
236 Correct 5670 ms 211796 KB Output is correct
237 Correct 5555 ms 212388 KB Output is correct
238 Correct 6325 ms 238160 KB Output is correct
239 Correct 5963 ms 220492 KB Output is correct
240 Correct 6357 ms 236784 KB Output is correct
241 Correct 6031 ms 271000 KB Output is correct
242 Correct 6348 ms 251064 KB Output is correct