Submission #504038

# Submission time Handle Problem Language Result Execution time Memory
504038 2022-01-09T14:49:44 Z rainboy Wells (CEOI21_wells) C
60 / 100
2957 ms 214676 KB
/* https://hsin.hr/ceoi/competition/ceoi2021_day2_editorial.pdf */
#include <stdio.h>
#include <stdlib.h>

#define N	1500000
#define SMALL	10000
#define MD	1000000007
#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 pp2[N + 1];

void init() {
	int i;

	pp2[0] = 1;
	for (i = 1; i <= N; i++)
		pp2[i] = pp2[i - 1] * 2 % MD;
}

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

int i_, l;
int ii[N]; char path[N];

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

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

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

int gg[N], dd[N], hh[N];

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

	gg[i] = g, dd[i] = d, hh[i] = 0;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p && !path[j]) {
			dfs2(i, j, g, d + 1);
			hh[i] = max(hh[i], hh[j] + 1);
		}
	}
}

int dfs3(int p, int i, int d) {
	int o, x;

	if (d == 0 || type[i] == -1)
		return 1;
	x = 1;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p)
			x = (long long) x * dfs3(i, j, d - 1) % MD;
	}
	return (x + 1) % MD;
}

int cc[N], dp[N], dq[N], dr[N];

int dfs4(int p, int i) {
	int o, p1, p2;

	dp[i] = -INF, dq[i] = 0, dr[i] = -1, p1 = p2 = -INF;
	for (o = eo[i]; o--; ) {
		int j = ej[i][o];

		if (j != p && !path[j] && type[j] == 1) {
			if (!dfs4(i, j))
				return 0;
			dp[i] = max(dp[i], dp[j]);
			if (p1 < dp[j])
				p2 = p1, p1 = dp[j];
			else if (p2 < dp[j])
				p2 = dp[j];
			if (cc[i] == 0 && dq[i] + dq[j] + 1 >= k - 1)
				return 0;
			dq[i] = max(dq[i], dq[j] + 1);
			if (dr[j] != -1)
				dr[i] = dr[j] + 1;
		}
	}
	if (cc[i] == 1)
		dp[i] = hh[i], dq[i] = -1, dr[i] = 0;
	else if (p2 != -INF && dr[i] * 2 <= k - 1 && dr[i] * 2 + p1 + p2 >= k - 1)
		return 0;
	return 1;
}

char bad[N]; int xx[N];

void mark_bad_and_count() {
	static int aa[N + 1];
	static int yy[N], zz[N];
	int g, r, i, d;

	for (g = 0; g < l; g++)
		if (type[ii[g]] == 1) {
			int lower, upper;

			lower = g + 1, upper = min(g * 2, k - 1);
			if (lower <= upper)
				aa[lower]++, aa[upper + 1]--;
			lower = max(g * 2 - l + 1, l - k), upper = g - 1;
			if (lower <= upper) {
				lower %= k, upper %= k;
				aa[lower]++, aa[upper + 1]--;
				if (lower > upper)
					aa[0]++;
			}
		}
	for (r = 1; r < k; r++)
		aa[r] += aa[r - 1];
	for (r = 0; r < k; r++)
		if (aa[r])
			bad[r] = 1;
	for (i = 0; i < n; i++)
		if (!path[i] && type[i] == 1) {
			int r1, r2;

			g = gg[i], d = dd[i];
			r1 = (g + d) % k, r2 = (g - d % k + k) % k;
			if (r1 != r2) {
				if (g >= r1 && g <= (l - 1 - r1) / k * k + r1)
					bad[r1] = 1;
				if (g >= r2 && g <= (l - 1 - r2) / k * k + r2)
					bad[r2] = 1;
			}
		}
	for (r = 0; r < k; r++)
		yy[r] = zz[r] = 1;
	for (i = 0; i < n; i++)
		if (!path[i] && type[i] == 0 && (path[pp[i]] || type[pp[i]] == 1)) {
			g = gg[i], d = dd[i];
			if (g + dd[i] + hh[i] >= k - 1) {
				if (g + 1 < k)
					yy[g + 1] = (long long) yy[g + 1] * dfs3(pp[i], i, k - 1 - (g + dd[i])) % MD;
			} else {
				if (g > l - k)
					zz[g - 1 - l + k] = (long long) zz[g - 1 - l + k] * dfs3(pp[i], i, k - 1 - (l - 1 - g + dd[i])) % MD;
			}
		}
	for (r = 1; r < k; r++)
		yy[r] = (long long) yy[r] * yy[r - 1] % MD;
	for (r = k - 2; r >= 0; r--)
		zz[r] = (long long) zz[r] * zz[r + 1] % MD;
	for (r = 0; r < k; r++)
		xx[r] = (long long) yy[r] * zz[(r + l) % k] % MD;
}

int yes, ans;

void try(int r) {
	int g, i, d;

	if (bad[r])
		return;
	for (i = 0; i < n; i++) {
		g = gg[i], d = dd[i];
		if (path[i])
			cc[i] = g % k == r ? 1 : 0;
		else if (type[i] == 1)
			cc[i] = g >= r ? ((g + d) % k == r ? 1 : 0) : ((g - d % k + k) % k == r ? 1 : 0);
	}
	for (g = 0; g < l; g++)
		if (type[ii[g]] == 1 && !dfs4(-1, ii[g]))
			return;
	yes = 1, ans = (ans + xx[r]) % MD;
}

int main() {
	static int uu[N - 1], vv[N - 1];
	int g, h, i, j, u, v, d, r, deep;

	init();
	scanf("%d%d", &n, &k);
	if (k == 2) {
		printf("YES\n");
		printf("2\n");
		return 0;
	}
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		uu[h] = i, vv[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 = uu[h], j = vv[h];
		ej[i][eo[i]++] = j, ej[j][eo[j]++] = i;
	}
	i_ = -1, l = -1, dfs1(-1, 0, 0), u = i_;
	i_ = -1, l = -1, dfs1(-1, u, 0), v = i_;
	if (l < k) {
		printf("YES\n");
		printf("%d\n", pp2[n]);
		return 0;
	}
	for (i = v, d = l - 1; i != u; i = pp[i], d--)
		path[ii[d] = i] = 1;
	path[ii[0] = u] = 1;
	for (g = 0; g < l; g++)
		dfs2(-1, ii[g], g, 0);
	for (i = 0; i < n; i++) {
		g = gg[i];
		if (max(g, l - 1 - g) + dd[i] + hh[i] < k - 1)
			type[i] = -1;
		else if (min(g, l - 1 - g) + dd[i] + hh[i] >= k - 1)
			type[i] = 1;
		else
			type[i] = 0;
	}
	mark_bad_and_count();
	yes = 0, ans = 0;
	deep = 0;
	for (i = 0; i < n; i++)
		if (dd[i] * 2 >= k - 1) {
			deep = 1;
			break;
		}
	if (deep || n <= SMALL)
		for (r = 0; r < k; r++)
			try(r);
	else {
		for (r = 0; r < k; r++)
			if (!bad[r]) {
				printf("YES\n");
				printf("0\n");
				return 0;
			}
		printf("NO\n");
		printf("0\n");
		return 0;
	}
	if (yes) {
		printf("YES\n");
		for (i = 0; i < n; i++)
			if (!path[i] && type[i] == -1)
				ans = ans * 2 % MD;
		printf("%d\n", ans);
	} else {
		printf("NO\n");
		printf("0\n");
	}
	return 0;
}

Compilation message

wells.c: In function 'main':
wells.c:192:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
  192 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
wells.c:199:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
  199 |   scanf("%d%d", &i, &j), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6092 KB Output is correct
2 Correct 8 ms 6220 KB Output is correct
3 Correct 8 ms 6244 KB Output is correct
4 Correct 8 ms 6220 KB Output is correct
5 Correct 8 ms 6220 KB Output is correct
6 Correct 9 ms 6292 KB Output is correct
7 Correct 8 ms 6292 KB Output is correct
8 Correct 8 ms 6308 KB Output is correct
9 Correct 10 ms 6292 KB Output is correct
10 Correct 9 ms 6308 KB Output is correct
11 Correct 9 ms 6280 KB Output is correct
12 Correct 8 ms 6160 KB Output is correct
13 Correct 9 ms 6248 KB Output is correct
14 Correct 8 ms 6224 KB Output is correct
15 Correct 8 ms 6288 KB Output is correct
16 Correct 8 ms 6256 KB Output is correct
17 Correct 8 ms 6220 KB Output is correct
18 Correct 8 ms 6220 KB Output is correct
19 Correct 8 ms 6220 KB Output is correct
20 Correct 8 ms 6220 KB Output is correct
21 Correct 8 ms 6292 KB Output is correct
22 Correct 8 ms 6220 KB Output is correct
23 Correct 9 ms 6292 KB Output is correct
24 Correct 9 ms 6220 KB Output is correct
25 Correct 9 ms 6220 KB Output is correct
26 Correct 9 ms 6292 KB Output is correct
27 Correct 8 ms 6220 KB Output is correct
28 Correct 9 ms 6284 KB Output is correct
29 Correct 10 ms 6220 KB Output is correct
30 Correct 8 ms 6232 KB Output is correct
31 Correct 8 ms 6216 KB Output is correct
32 Correct 8 ms 6316 KB Output is correct
33 Correct 8 ms 6220 KB Output is correct
34 Correct 8 ms 6288 KB Output is correct
35 Correct 8 ms 6308 KB Output is correct
36 Correct 8 ms 6272 KB Output is correct
37 Correct 8 ms 6220 KB Output is correct
38 Correct 8 ms 6280 KB Output is correct
39 Correct 9 ms 6288 KB Output is correct
40 Correct 9 ms 6228 KB Output is correct
41 Correct 8 ms 6220 KB Output is correct
42 Correct 9 ms 6220 KB Output is correct
43 Correct 9 ms 6328 KB Output is correct
44 Correct 9 ms 6220 KB Output is correct
45 Correct 9 ms 6288 KB Output is correct
46 Correct 9 ms 6348 KB Output is correct
47 Correct 9 ms 6288 KB Output is correct
48 Correct 8 ms 6292 KB Output is correct
49 Correct 8 ms 6288 KB Output is correct
50 Correct 8 ms 6296 KB Output is correct
51 Correct 8 ms 6292 KB Output is correct
52 Partially correct 9 ms 6220 KB Output is partially correct
53 Correct 8 ms 6276 KB Output is correct
54 Correct 9 ms 6296 KB Output is correct
55 Correct 8 ms 6300 KB Output is correct
56 Correct 9 ms 6212 KB Output is correct
57 Correct 10 ms 6248 KB Output is correct
58 Correct 9 ms 6220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6092 KB Output is correct
2 Correct 8 ms 6220 KB Output is correct
3 Correct 8 ms 6244 KB Output is correct
4 Correct 8 ms 6220 KB Output is correct
5 Correct 8 ms 6220 KB Output is correct
6 Correct 9 ms 6292 KB Output is correct
7 Correct 8 ms 6292 KB Output is correct
8 Correct 8 ms 6308 KB Output is correct
9 Correct 10 ms 6292 KB Output is correct
10 Correct 9 ms 6308 KB Output is correct
11 Correct 9 ms 6280 KB Output is correct
12 Correct 8 ms 6160 KB Output is correct
13 Correct 9 ms 6248 KB Output is correct
14 Correct 8 ms 6224 KB Output is correct
15 Correct 8 ms 6288 KB Output is correct
16 Correct 8 ms 6256 KB Output is correct
17 Correct 8 ms 6220 KB Output is correct
18 Correct 8 ms 6220 KB Output is correct
19 Correct 8 ms 6220 KB Output is correct
20 Correct 8 ms 6220 KB Output is correct
21 Correct 8 ms 6292 KB Output is correct
22 Correct 8 ms 6220 KB Output is correct
23 Correct 9 ms 6292 KB Output is correct
24 Correct 9 ms 6220 KB Output is correct
25 Correct 9 ms 6220 KB Output is correct
26 Correct 9 ms 6292 KB Output is correct
27 Correct 8 ms 6220 KB Output is correct
28 Correct 9 ms 6284 KB Output is correct
29 Correct 10 ms 6220 KB Output is correct
30 Correct 8 ms 6232 KB Output is correct
31 Correct 8 ms 6216 KB Output is correct
32 Correct 8 ms 6316 KB Output is correct
33 Correct 8 ms 6220 KB Output is correct
34 Correct 8 ms 6288 KB Output is correct
35 Correct 8 ms 6308 KB Output is correct
36 Correct 8 ms 6272 KB Output is correct
37 Correct 8 ms 6220 KB Output is correct
38 Correct 8 ms 6280 KB Output is correct
39 Correct 9 ms 6288 KB Output is correct
40 Correct 9 ms 6228 KB Output is correct
41 Correct 8 ms 6220 KB Output is correct
42 Correct 9 ms 6220 KB Output is correct
43 Correct 9 ms 6328 KB Output is correct
44 Correct 9 ms 6220 KB Output is correct
45 Correct 9 ms 6288 KB Output is correct
46 Correct 9 ms 6348 KB Output is correct
47 Correct 9 ms 6288 KB Output is correct
48 Correct 8 ms 6292 KB Output is correct
49 Correct 8 ms 6288 KB Output is correct
50 Correct 8 ms 6296 KB Output is correct
51 Correct 8 ms 6292 KB Output is correct
52 Partially correct 9 ms 6220 KB Output is partially correct
53 Correct 8 ms 6276 KB Output is correct
54 Correct 9 ms 6296 KB Output is correct
55 Correct 8 ms 6300 KB Output is correct
56 Correct 9 ms 6212 KB Output is correct
57 Correct 10 ms 6248 KB Output is correct
58 Correct 9 ms 6220 KB Output is correct
59 Correct 8 ms 6164 KB Output is correct
60 Correct 10 ms 6556 KB Output is correct
61 Correct 9 ms 6432 KB Output is correct
62 Correct 9 ms 6604 KB Output is correct
63 Correct 11 ms 7104 KB Output is correct
64 Correct 12 ms 7532 KB Output is correct
65 Correct 12 ms 6940 KB Output is correct
66 Correct 13 ms 6976 KB Output is correct
67 Correct 37 ms 7600 KB Output is correct
68 Correct 11 ms 6684 KB Output is correct
69 Correct 10 ms 6432 KB Output is correct
70 Correct 11 ms 6724 KB Output is correct
71 Correct 10 ms 6688 KB Output is correct
72 Correct 10 ms 6684 KB Output is correct
73 Correct 33 ms 6744 KB Output is correct
74 Correct 129 ms 7188 KB Output is correct
75 Correct 31 ms 6908 KB Output is correct
76 Correct 16 ms 7064 KB Output is correct
77 Partially correct 11 ms 6484 KB Output is partially correct
78 Correct 13 ms 6604 KB Output is correct
79 Partially correct 9 ms 6604 KB Output is partially correct
80 Correct 76 ms 6944 KB Output is correct
81 Correct 84 ms 7040 KB Output is correct
82 Correct 26 ms 6948 KB Output is correct
83 Correct 49 ms 7208 KB Output is correct
84 Correct 11 ms 6860 KB Output is correct
85 Correct 113 ms 7244 KB Output is correct
86 Correct 11 ms 6980 KB Output is correct
87 Correct 11 ms 7184 KB Output is correct
88 Correct 12 ms 7248 KB Output is correct
89 Correct 11 ms 7012 KB Output is correct
90 Correct 35 ms 6684 KB Output is correct
91 Correct 44 ms 7104 KB Output is correct
92 Correct 122 ms 7396 KB Output is correct
93 Correct 19 ms 7244 KB Output is correct
94 Partially correct 14 ms 6940 KB Output is partially correct
95 Partially correct 15 ms 6844 KB Output is partially correct
96 Correct 11 ms 6608 KB Output is correct
97 Correct 37 ms 6772 KB Output is correct
98 Correct 38 ms 6788 KB Output is correct
99 Correct 22 ms 6736 KB Output is correct
100 Correct 58 ms 7116 KB Output is correct
101 Correct 23 ms 6988 KB Output is correct
102 Correct 50 ms 7200 KB Output is correct
103 Correct 10 ms 7048 KB Output is correct
104 Correct 13 ms 7244 KB Output is correct
105 Correct 11 ms 7280 KB Output is correct
106 Correct 13 ms 6996 KB Output is correct
107 Correct 11 ms 7352 KB Output is correct
108 Correct 14 ms 7068 KB Output is correct
109 Correct 12 ms 7068 KB Output is correct
110 Correct 16 ms 7100 KB Output is correct
111 Correct 15 ms 7144 KB Output is correct
112 Correct 13 ms 7244 KB Output is correct
113 Correct 12 ms 7084 KB Output is correct
114 Correct 11 ms 7148 KB Output is correct
115 Correct 11 ms 7068 KB Output is correct
116 Correct 12 ms 7340 KB Output is correct
117 Correct 11 ms 6996 KB Output is correct
118 Correct 11 ms 7364 KB Output is correct
119 Correct 13 ms 7048 KB Output is correct
120 Correct 12 ms 7372 KB Output is correct
121 Correct 202 ms 7268 KB Output is correct
122 Correct 172 ms 7228 KB Output is correct
123 Correct 78 ms 7108 KB Output is correct
124 Correct 11 ms 7244 KB Output is correct
125 Correct 13 ms 6988 KB Output is correct
126 Correct 21 ms 6868 KB Output is correct
127 Correct 251 ms 7424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6092 KB Output is correct
2 Correct 8 ms 6220 KB Output is correct
3 Correct 8 ms 6244 KB Output is correct
4 Correct 8 ms 6220 KB Output is correct
5 Correct 8 ms 6220 KB Output is correct
6 Correct 9 ms 6292 KB Output is correct
7 Correct 8 ms 6292 KB Output is correct
8 Correct 8 ms 6308 KB Output is correct
9 Correct 10 ms 6292 KB Output is correct
10 Correct 9 ms 6308 KB Output is correct
11 Correct 9 ms 6280 KB Output is correct
12 Correct 8 ms 6160 KB Output is correct
13 Correct 9 ms 6248 KB Output is correct
14 Correct 8 ms 6224 KB Output is correct
15 Correct 8 ms 6288 KB Output is correct
16 Correct 8 ms 6256 KB Output is correct
17 Correct 8 ms 6220 KB Output is correct
18 Correct 8 ms 6220 KB Output is correct
19 Correct 8 ms 6220 KB Output is correct
20 Correct 8 ms 6220 KB Output is correct
21 Correct 8 ms 6292 KB Output is correct
22 Correct 8 ms 6220 KB Output is correct
23 Correct 9 ms 6292 KB Output is correct
24 Correct 9 ms 6220 KB Output is correct
25 Correct 9 ms 6220 KB Output is correct
26 Correct 9 ms 6292 KB Output is correct
27 Correct 8 ms 6220 KB Output is correct
28 Correct 9 ms 6284 KB Output is correct
29 Correct 10 ms 6220 KB Output is correct
30 Correct 8 ms 6232 KB Output is correct
31 Correct 8 ms 6216 KB Output is correct
32 Correct 8 ms 6316 KB Output is correct
33 Correct 8 ms 6220 KB Output is correct
34 Correct 8 ms 6288 KB Output is correct
35 Correct 8 ms 6308 KB Output is correct
36 Correct 8 ms 6272 KB Output is correct
37 Correct 8 ms 6220 KB Output is correct
38 Correct 8 ms 6280 KB Output is correct
39 Correct 9 ms 6288 KB Output is correct
40 Correct 9 ms 6228 KB Output is correct
41 Correct 8 ms 6220 KB Output is correct
42 Correct 9 ms 6220 KB Output is correct
43 Correct 9 ms 6328 KB Output is correct
44 Correct 9 ms 6220 KB Output is correct
45 Correct 9 ms 6288 KB Output is correct
46 Correct 9 ms 6348 KB Output is correct
47 Correct 9 ms 6288 KB Output is correct
48 Correct 8 ms 6292 KB Output is correct
49 Correct 8 ms 6288 KB Output is correct
50 Correct 8 ms 6296 KB Output is correct
51 Correct 8 ms 6292 KB Output is correct
52 Partially correct 9 ms 6220 KB Output is partially correct
53 Correct 8 ms 6276 KB Output is correct
54 Correct 9 ms 6296 KB Output is correct
55 Correct 8 ms 6300 KB Output is correct
56 Correct 9 ms 6212 KB Output is correct
57 Correct 10 ms 6248 KB Output is correct
58 Correct 9 ms 6220 KB Output is correct
59 Correct 8 ms 6164 KB Output is correct
60 Correct 10 ms 6556 KB Output is correct
61 Correct 9 ms 6432 KB Output is correct
62 Correct 9 ms 6604 KB Output is correct
63 Correct 11 ms 7104 KB Output is correct
64 Correct 12 ms 7532 KB Output is correct
65 Correct 12 ms 6940 KB Output is correct
66 Correct 13 ms 6976 KB Output is correct
67 Correct 37 ms 7600 KB Output is correct
68 Correct 11 ms 6684 KB Output is correct
69 Correct 10 ms 6432 KB Output is correct
70 Correct 11 ms 6724 KB Output is correct
71 Correct 10 ms 6688 KB Output is correct
72 Correct 10 ms 6684 KB Output is correct
73 Correct 33 ms 6744 KB Output is correct
74 Correct 129 ms 7188 KB Output is correct
75 Correct 31 ms 6908 KB Output is correct
76 Correct 16 ms 7064 KB Output is correct
77 Partially correct 11 ms 6484 KB Output is partially correct
78 Correct 13 ms 6604 KB Output is correct
79 Partially correct 9 ms 6604 KB Output is partially correct
80 Correct 76 ms 6944 KB Output is correct
81 Correct 84 ms 7040 KB Output is correct
82 Correct 26 ms 6948 KB Output is correct
83 Correct 49 ms 7208 KB Output is correct
84 Correct 11 ms 6860 KB Output is correct
85 Correct 113 ms 7244 KB Output is correct
86 Correct 11 ms 6980 KB Output is correct
87 Correct 11 ms 7184 KB Output is correct
88 Correct 12 ms 7248 KB Output is correct
89 Correct 11 ms 7012 KB Output is correct
90 Correct 35 ms 6684 KB Output is correct
91 Correct 44 ms 7104 KB Output is correct
92 Correct 122 ms 7396 KB Output is correct
93 Correct 19 ms 7244 KB Output is correct
94 Partially correct 14 ms 6940 KB Output is partially correct
95 Partially correct 15 ms 6844 KB Output is partially correct
96 Correct 11 ms 6608 KB Output is correct
97 Correct 37 ms 6772 KB Output is correct
98 Correct 38 ms 6788 KB Output is correct
99 Correct 22 ms 6736 KB Output is correct
100 Correct 58 ms 7116 KB Output is correct
101 Correct 23 ms 6988 KB Output is correct
102 Correct 50 ms 7200 KB Output is correct
103 Correct 10 ms 7048 KB Output is correct
104 Correct 13 ms 7244 KB Output is correct
105 Correct 11 ms 7280 KB Output is correct
106 Correct 13 ms 6996 KB Output is correct
107 Correct 11 ms 7352 KB Output is correct
108 Correct 14 ms 7068 KB Output is correct
109 Correct 12 ms 7068 KB Output is correct
110 Correct 16 ms 7100 KB Output is correct
111 Correct 15 ms 7144 KB Output is correct
112 Correct 13 ms 7244 KB Output is correct
113 Correct 12 ms 7084 KB Output is correct
114 Correct 11 ms 7148 KB Output is correct
115 Correct 11 ms 7068 KB Output is correct
116 Correct 12 ms 7340 KB Output is correct
117 Correct 11 ms 6996 KB Output is correct
118 Correct 11 ms 7364 KB Output is correct
119 Correct 13 ms 7048 KB Output is correct
120 Correct 12 ms 7372 KB Output is correct
121 Correct 202 ms 7268 KB Output is correct
122 Correct 172 ms 7228 KB Output is correct
123 Correct 78 ms 7108 KB Output is correct
124 Correct 11 ms 7244 KB Output is correct
125 Correct 13 ms 6988 KB Output is correct
126 Correct 21 ms 6868 KB Output is correct
127 Correct 251 ms 7424 KB Output is correct
128 Correct 8 ms 6268 KB Output is correct
129 Correct 120 ms 20680 KB Output is correct
130 Correct 153 ms 30172 KB Output is correct
131 Correct 138 ms 32892 KB Output is correct
132 Correct 108 ms 19148 KB Output is correct
133 Partially correct 132 ms 22028 KB Output is partially correct
134 Partially correct 108 ms 22084 KB Output is partially correct
135 Correct 143 ms 18956 KB Output is correct
136 Correct 140 ms 23060 KB Output is correct
137 Partially correct 98 ms 20488 KB Output is partially correct
138 Partially correct 95 ms 28924 KB Output is partially correct
139 Correct 349 ms 41948 KB Output is correct
140 Partially correct 359 ms 48272 KB Output is partially correct
141 Correct 399 ms 37692 KB Output is correct
142 Correct 569 ms 51360 KB Output is correct
143 Correct 592 ms 50020 KB Output is correct
144 Correct 519 ms 45636 KB Output is correct
145 Partially correct 442 ms 60560 KB Output is partially correct
146 Partially correct 322 ms 40180 KB Output is partially correct
147 Partially correct 341 ms 56500 KB Output is partially correct
148 Correct 728 ms 37340 KB Output is correct
149 Partially correct 112 ms 18536 KB Output is partially correct
150 Correct 131 ms 20812 KB Output is correct
151 Correct 136 ms 25064 KB Output is correct
152 Correct 123 ms 20216 KB Output is correct
153 Correct 176 ms 19736 KB Output is correct
154 Correct 147 ms 19180 KB Output is correct
155 Correct 143 ms 24164 KB Output is correct
156 Partially correct 99 ms 22032 KB Output is partially correct
157 Correct 91 ms 18716 KB Output is correct
158 Partially correct 117 ms 20356 KB Output is partially correct
159 Partially correct 114 ms 26268 KB Output is partially correct
160 Partially correct 289 ms 34436 KB Output is partially correct
161 Partially correct 411 ms 48404 KB Output is partially correct
162 Correct 579 ms 65272 KB Output is correct
163 Correct 561 ms 56692 KB Output is correct
164 Partially correct 495 ms 56216 KB Output is partially correct
165 Partially correct 479 ms 40212 KB Output is partially correct
166 Partially correct 402 ms 40440 KB Output is partially correct
167 Correct 652 ms 59268 KB Output is correct
168 Partially correct 309 ms 43320 KB Output is partially correct
169 Partially correct 329 ms 44100 KB Output is partially correct
170 Partially correct 274 ms 38088 KB Output is partially correct
171 Correct 491 ms 29636 KB Output is correct
172 Correct 563 ms 39724 KB Output is correct
173 Correct 480 ms 50076 KB Output is correct
174 Correct 438 ms 51508 KB Output is correct
175 Correct 420 ms 46480 KB Output is correct
176 Correct 440 ms 45636 KB Output is correct
177 Correct 411 ms 45904 KB Output is correct
178 Correct 559 ms 65136 KB Output is correct
179 Partially correct 290 ms 44188 KB Output is partially correct
180 Partially correct 294 ms 44176 KB Output is partially correct
181 Partially correct 326 ms 28592 KB Output is partially correct
182 Correct 427 ms 45764 KB Output is correct
183 Correct 580 ms 55072 KB Output is correct
184 Partially correct 404 ms 37532 KB Output is partially correct
185 Partially correct 411 ms 35188 KB Output is partially correct
186 Partially correct 339 ms 32540 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 6092 KB Output is correct
2 Correct 8 ms 6220 KB Output is correct
3 Correct 8 ms 6244 KB Output is correct
4 Correct 8 ms 6220 KB Output is correct
5 Correct 8 ms 6220 KB Output is correct
6 Correct 9 ms 6292 KB Output is correct
7 Correct 8 ms 6292 KB Output is correct
8 Correct 8 ms 6308 KB Output is correct
9 Correct 10 ms 6292 KB Output is correct
10 Correct 9 ms 6308 KB Output is correct
11 Correct 9 ms 6280 KB Output is correct
12 Correct 8 ms 6160 KB Output is correct
13 Correct 9 ms 6248 KB Output is correct
14 Correct 8 ms 6224 KB Output is correct
15 Correct 8 ms 6288 KB Output is correct
16 Correct 8 ms 6256 KB Output is correct
17 Correct 8 ms 6220 KB Output is correct
18 Correct 8 ms 6220 KB Output is correct
19 Correct 8 ms 6220 KB Output is correct
20 Correct 8 ms 6220 KB Output is correct
21 Correct 8 ms 6292 KB Output is correct
22 Correct 8 ms 6220 KB Output is correct
23 Correct 9 ms 6292 KB Output is correct
24 Correct 9 ms 6220 KB Output is correct
25 Correct 9 ms 6220 KB Output is correct
26 Correct 9 ms 6292 KB Output is correct
27 Correct 8 ms 6220 KB Output is correct
28 Correct 9 ms 6284 KB Output is correct
29 Correct 10 ms 6220 KB Output is correct
30 Correct 8 ms 6232 KB Output is correct
31 Correct 8 ms 6216 KB Output is correct
32 Correct 8 ms 6316 KB Output is correct
33 Correct 8 ms 6220 KB Output is correct
34 Correct 8 ms 6288 KB Output is correct
35 Correct 8 ms 6308 KB Output is correct
36 Correct 8 ms 6272 KB Output is correct
37 Correct 8 ms 6220 KB Output is correct
38 Correct 8 ms 6280 KB Output is correct
39 Correct 9 ms 6288 KB Output is correct
40 Correct 9 ms 6228 KB Output is correct
41 Correct 8 ms 6220 KB Output is correct
42 Correct 9 ms 6220 KB Output is correct
43 Correct 9 ms 6328 KB Output is correct
44 Correct 9 ms 6220 KB Output is correct
45 Correct 9 ms 6288 KB Output is correct
46 Correct 9 ms 6348 KB Output is correct
47 Correct 9 ms 6288 KB Output is correct
48 Correct 8 ms 6292 KB Output is correct
49 Correct 8 ms 6288 KB Output is correct
50 Correct 8 ms 6296 KB Output is correct
51 Correct 8 ms 6292 KB Output is correct
52 Partially correct 9 ms 6220 KB Output is partially correct
53 Correct 8 ms 6276 KB Output is correct
54 Correct 9 ms 6296 KB Output is correct
55 Correct 8 ms 6300 KB Output is correct
56 Correct 9 ms 6212 KB Output is correct
57 Correct 10 ms 6248 KB Output is correct
58 Correct 9 ms 6220 KB Output is correct
59 Correct 8 ms 6164 KB Output is correct
60 Correct 10 ms 6556 KB Output is correct
61 Correct 9 ms 6432 KB Output is correct
62 Correct 9 ms 6604 KB Output is correct
63 Correct 11 ms 7104 KB Output is correct
64 Correct 12 ms 7532 KB Output is correct
65 Correct 12 ms 6940 KB Output is correct
66 Correct 13 ms 6976 KB Output is correct
67 Correct 37 ms 7600 KB Output is correct
68 Correct 11 ms 6684 KB Output is correct
69 Correct 10 ms 6432 KB Output is correct
70 Correct 11 ms 6724 KB Output is correct
71 Correct 10 ms 6688 KB Output is correct
72 Correct 10 ms 6684 KB Output is correct
73 Correct 33 ms 6744 KB Output is correct
74 Correct 129 ms 7188 KB Output is correct
75 Correct 31 ms 6908 KB Output is correct
76 Correct 16 ms 7064 KB Output is correct
77 Partially correct 11 ms 6484 KB Output is partially correct
78 Correct 13 ms 6604 KB Output is correct
79 Partially correct 9 ms 6604 KB Output is partially correct
80 Correct 76 ms 6944 KB Output is correct
81 Correct 84 ms 7040 KB Output is correct
82 Correct 26 ms 6948 KB Output is correct
83 Correct 49 ms 7208 KB Output is correct
84 Correct 11 ms 6860 KB Output is correct
85 Correct 113 ms 7244 KB Output is correct
86 Correct 11 ms 6980 KB Output is correct
87 Correct 11 ms 7184 KB Output is correct
88 Correct 12 ms 7248 KB Output is correct
89 Correct 11 ms 7012 KB Output is correct
90 Correct 35 ms 6684 KB Output is correct
91 Correct 44 ms 7104 KB Output is correct
92 Correct 122 ms 7396 KB Output is correct
93 Correct 19 ms 7244 KB Output is correct
94 Partially correct 14 ms 6940 KB Output is partially correct
95 Partially correct 15 ms 6844 KB Output is partially correct
96 Correct 11 ms 6608 KB Output is correct
97 Correct 37 ms 6772 KB Output is correct
98 Correct 38 ms 6788 KB Output is correct
99 Correct 22 ms 6736 KB Output is correct
100 Correct 58 ms 7116 KB Output is correct
101 Correct 23 ms 6988 KB Output is correct
102 Correct 50 ms 7200 KB Output is correct
103 Correct 10 ms 7048 KB Output is correct
104 Correct 13 ms 7244 KB Output is correct
105 Correct 11 ms 7280 KB Output is correct
106 Correct 13 ms 6996 KB Output is correct
107 Correct 11 ms 7352 KB Output is correct
108 Correct 14 ms 7068 KB Output is correct
109 Correct 12 ms 7068 KB Output is correct
110 Correct 16 ms 7100 KB Output is correct
111 Correct 15 ms 7144 KB Output is correct
112 Correct 13 ms 7244 KB Output is correct
113 Correct 12 ms 7084 KB Output is correct
114 Correct 11 ms 7148 KB Output is correct
115 Correct 11 ms 7068 KB Output is correct
116 Correct 12 ms 7340 KB Output is correct
117 Correct 11 ms 6996 KB Output is correct
118 Correct 11 ms 7364 KB Output is correct
119 Correct 13 ms 7048 KB Output is correct
120 Correct 12 ms 7372 KB Output is correct
121 Correct 202 ms 7268 KB Output is correct
122 Correct 172 ms 7228 KB Output is correct
123 Correct 78 ms 7108 KB Output is correct
124 Correct 11 ms 7244 KB Output is correct
125 Correct 13 ms 6988 KB Output is correct
126 Correct 21 ms 6868 KB Output is correct
127 Correct 251 ms 7424 KB Output is correct
128 Correct 8 ms 6268 KB Output is correct
129 Correct 120 ms 20680 KB Output is correct
130 Correct 153 ms 30172 KB Output is correct
131 Correct 138 ms 32892 KB Output is correct
132 Correct 108 ms 19148 KB Output is correct
133 Partially correct 132 ms 22028 KB Output is partially correct
134 Partially correct 108 ms 22084 KB Output is partially correct
135 Correct 143 ms 18956 KB Output is correct
136 Correct 140 ms 23060 KB Output is correct
137 Partially correct 98 ms 20488 KB Output is partially correct
138 Partially correct 95 ms 28924 KB Output is partially correct
139 Correct 349 ms 41948 KB Output is correct
140 Partially correct 359 ms 48272 KB Output is partially correct
141 Correct 399 ms 37692 KB Output is correct
142 Correct 569 ms 51360 KB Output is correct
143 Correct 592 ms 50020 KB Output is correct
144 Correct 519 ms 45636 KB Output is correct
145 Partially correct 442 ms 60560 KB Output is partially correct
146 Partially correct 322 ms 40180 KB Output is partially correct
147 Partially correct 341 ms 56500 KB Output is partially correct
148 Correct 728 ms 37340 KB Output is correct
149 Partially correct 112 ms 18536 KB Output is partially correct
150 Correct 131 ms 20812 KB Output is correct
151 Correct 136 ms 25064 KB Output is correct
152 Correct 123 ms 20216 KB Output is correct
153 Correct 176 ms 19736 KB Output is correct
154 Correct 147 ms 19180 KB Output is correct
155 Correct 143 ms 24164 KB Output is correct
156 Partially correct 99 ms 22032 KB Output is partially correct
157 Correct 91 ms 18716 KB Output is correct
158 Partially correct 117 ms 20356 KB Output is partially correct
159 Partially correct 114 ms 26268 KB Output is partially correct
160 Partially correct 289 ms 34436 KB Output is partially correct
161 Partially correct 411 ms 48404 KB Output is partially correct
162 Correct 579 ms 65272 KB Output is correct
163 Correct 561 ms 56692 KB Output is correct
164 Partially correct 495 ms 56216 KB Output is partially correct
165 Partially correct 479 ms 40212 KB Output is partially correct
166 Partially correct 402 ms 40440 KB Output is partially correct
167 Correct 652 ms 59268 KB Output is correct
168 Partially correct 309 ms 43320 KB Output is partially correct
169 Partially correct 329 ms 44100 KB Output is partially correct
170 Partially correct 274 ms 38088 KB Output is partially correct
171 Correct 491 ms 29636 KB Output is correct
172 Correct 563 ms 39724 KB Output is correct
173 Correct 480 ms 50076 KB Output is correct
174 Correct 438 ms 51508 KB Output is correct
175 Correct 420 ms 46480 KB Output is correct
176 Correct 440 ms 45636 KB Output is correct
177 Correct 411 ms 45904 KB Output is correct
178 Correct 559 ms 65136 KB Output is correct
179 Partially correct 290 ms 44188 KB Output is partially correct
180 Partially correct 294 ms 44176 KB Output is partially correct
181 Partially correct 326 ms 28592 KB Output is partially correct
182 Correct 427 ms 45764 KB Output is correct
183 Correct 580 ms 55072 KB Output is correct
184 Partially correct 404 ms 37532 KB Output is partially correct
185 Partially correct 411 ms 35188 KB Output is partially correct
186 Partially correct 339 ms 32540 KB Output is partially correct
187 Correct 2015 ms 134784 KB Output is correct
188 Partially correct 1405 ms 98000 KB Output is partially correct
189 Partially correct 1942 ms 121620 KB Output is partially correct
190 Partially correct 1440 ms 97936 KB Output is partially correct
191 Partially correct 1366 ms 98032 KB Output is partially correct
192 Partially correct 1347 ms 98116 KB Output is partially correct
193 Partially correct 1600 ms 111852 KB Output is partially correct
194 Correct 1566 ms 111808 KB Output is correct
195 Partially correct 1517 ms 92796 KB Output is partially correct
196 Partially correct 1477 ms 77528 KB Output is partially correct
197 Partially correct 1456 ms 93380 KB Output is partially correct
198 Partially correct 1516 ms 82236 KB Output is partially correct
199 Correct 1604 ms 75908 KB Output is correct
200 Partially correct 1436 ms 81148 KB Output is partially correct
201 Partially correct 1454 ms 76292 KB Output is partially correct
202 Correct 1949 ms 80092 KB Output is correct
203 Correct 1274 ms 86760 KB Output is correct
204 Correct 2417 ms 103696 KB Output is correct
205 Correct 2850 ms 103768 KB Output is correct
206 Correct 1983 ms 103716 KB Output is correct
207 Correct 2591 ms 103580 KB Output is correct
208 Correct 1666 ms 76040 KB Output is correct
209 Correct 2957 ms 133572 KB Output is correct
210 Partially correct 1425 ms 89648 KB Output is partially correct
211 Partially correct 1787 ms 101992 KB Output is partially correct
212 Correct 1934 ms 107168 KB Output is correct
213 Partially correct 1444 ms 89752 KB Output is partially correct
214 Partially correct 1609 ms 190036 KB Output is partially correct
215 Partially correct 1700 ms 182412 KB Output is partially correct
216 Correct 2271 ms 200924 KB Output is correct
217 Correct 1844 ms 78384 KB Output is correct
218 Correct 2306 ms 100408 KB Output is correct
219 Correct 1583 ms 113484 KB Output is correct
220 Partially correct 1620 ms 121804 KB Output is partially correct
221 Correct 1425 ms 84256 KB Output is correct
222 Partially correct 1433 ms 86492 KB Output is partially correct
223 Correct 2218 ms 164704 KB Output is correct
224 Correct 2327 ms 132600 KB Output is correct
225 Partially correct 1491 ms 113364 KB Output is partially correct
226 Partially correct 1718 ms 214676 KB Output is partially correct
227 Correct 2926 ms 100148 KB Output is correct
228 Correct 1911 ms 99748 KB Output is correct
229 Correct 1934 ms 147052 KB Output is correct
230 Partially correct 1489 ms 93292 KB Output is partially correct
231 Partially correct 1444 ms 83344 KB Output is partially correct
232 Partially correct 1462 ms 117564 KB Output is partially correct
233 Correct 2078 ms 181368 KB Output is correct
234 Correct 1509 ms 91952 KB Output is correct
235 Correct 1864 ms 154600 KB Output is correct
236 Correct 1675 ms 99764 KB Output is correct
237 Partially correct 1356 ms 79848 KB Output is partially correct
238 Correct 1711 ms 118436 KB Output is correct
239 Correct 1526 ms 103064 KB Output is correct
240 Correct 1551 ms 112980 KB Output is correct
241 Correct 1836 ms 146336 KB Output is correct
242 Correct 1669 ms 126276 KB Output is correct