Submission #525869

# Submission time Handle Problem Language Result Execution time Memory
525869 2022-02-13T04:30:21 Z koioi.org-koosaga Mountains and Valleys (CCO20_day1problem3) C++17
16 / 25
7000 ms 50292 KB
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
typedef long long lint;
typedef pair<lint, lint> pi;
const int MAXN = 500005;

struct edge{
	int s, e, x;
};

int n, m;
vector<int> gph[MAXN];
int par[20][MAXN], dep[MAXN];

int lca(int x, int y){
	if(dep[x] > dep[y]) swap(x, y);
	int dx = dep[y] - dep[x];
	for(int i = 0; dx; i++){
		if(dx & 1) y = par[i][y];
		dx >>= 1;
	}
	for(int i = 19; i >= 0; i--){
		if(par[i][x] != par[i][y]){
			x = par[i][x];
			y = par[i][y];
		}
	}
	if(x != y) return par[0][x];
	return x;
}

vector<int> ord;
int din[MAXN], dout[MAXN], piv;
int f[20][MAXN], far[MAXN], diam[MAXN], pfar[MAXN];
int g[MAXN];
vector<pi> fars[MAXN];
vector<pi> subDiams[MAXN];

int fPathMax(int x, int v){
	int ans = -1e9;
	for(int i = 0; v; i++){
		if(v & 1){
			ans = max(ans, f[i][x]);
			x = par[i][x];
		}
		v >>= 1;
	}
	return ans;
}

bool in(int u, int v){
	return din[u] <= din[v] && dout[v] <= dout[u];
}

void dfs(int x, int p = -1){
	ord.push_back(x);
	din[x] = ++piv;
	for(auto &y : gph[x]){
		if(y == p) continue;
		par[0][y] = x;
		dep[y] = dep[x] + 1;
		dfs(y, x);
	}
	dout[x] = piv;
}

bool vis[MAXN];

pi dfsl(int x, int p = -1){
	pi ret(0, x);
	for(auto &y : gph[x]){
		if(y == p || vis[y]) continue;
		auto ans = dfsl(y, x);
		ans.first++;
		ret = max(ret, ans);
	}
	return ret;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> m;
	vector<edge> qry;
	for(int i = 0; i < m; i++){
		int s, e, x; cin >> s >> e >> x;
		if(x == 1){
			gph[s].push_back(e);
			gph[e].push_back(s);
		}
		else{
			qry.push_back({s, e, x});
		}
	}
	dfs(0);
	for(int i = 1; i < 20; i++){
		for(int j = 0; j < n; j++){
			par[i][j] = par[i-1][par[i-1][j]];
		}
	}
	{
		// TODO: n^2
		for(int i = 0; i < n; i++){
			if(dep[i] >= 2){
				vis[i] = 1;
				vis[par[1][i]] = 1;
				auto x = dfsl(par[0][i]);
				g[i] = x.first;
				f[0][i] = dfsl(x.second).first;
				vis[i] = 0;
				vis[par[1][i]] = 0;
			}
		}
		// TODO: n^2
		for(int i = 0; i < n; i++){
			vis[i] = 1;
			for(auto &j : gph[i]){
				subDiams[i].emplace_back(dfsl(dfsl(j).second).first, j);
			}
			sort(all(subDiams[i]));
			reverse(all(subDiams[i]));
			vis[i] = 0;
		}
		for(int i = 1; i < 20; i++){
			for(int j = 0; j < n; j++){
				f[i][j] = max(f[i-1][j], f[i-1][par[i-1][j]]);
			}
		}
		reverse(all(ord));
		for(auto &i : ord){
			for(auto &j : gph[i]){
				if(j == par[0][i]) continue;
				far[i] = max(far[i], far[j] + 1);
				diam[i] = max({diam[i], diam[j], far[j] + 1});
				fars[i].emplace_back(far[j], j);
			}
			sort(all(fars[i]));
			reverse(all(fars[i]));
			if(sz(fars[i]) >= 2) diam[i] = max(diam[i], (int)fars[i][0].first + (int)fars[i][1].first + 2);
		}
		reverse(all(ord));
		for(auto &i : ord){
			if(i == 0) continue;
			for(auto &j : fars[par[0][i]]){
				if(j.second == i) continue;
				pfar[i] = j.first + 1;
				break;
			}
			fars[i].emplace_back(pfar[i], par[0][i]);
			sort(all(fars[i]));
			reverse(all(fars[i]));
		}
	}
	int ans = 2 * n - 2 - diam[0];
	for(auto &x : qry){
		int l = lca(x.s, x.e);
		int plen = dep[x.s] + dep[x.e] - 2 * dep[l] + 1;
		int maxPath = -1e9;
		if(dep[x.s] >= dep[l] + 2){
			maxPath = max(maxPath, fPathMax(x.s, dep[x.s] - dep[l] - 1) - 3 + plen);
		}
		if(dep[x.e] >= dep[l] + 2){
			maxPath = max(maxPath, fPathMax(x.e, dep[x.e] - dep[l] - 1) - 3 + plen);
		}
		if(l != x.s){
			maxPath = max(maxPath, diam[x.s] - 3 + plen);
		}
		if(l != x.e){
			maxPath = max(maxPath, diam[x.e] - 3 + plen);
		}
		{
			int new_diam = 0;
			int cnt = 0;
			// passes through l
			for(auto &[d, v] : fars[l]){
				if((in(v, x.s) || in(v, x.e)) && v != par[0][l]) continue;
				new_diam += d + 1;
				cnt += 1;
				if(cnt == 2) break;
			}
			for(auto &[d, v] : subDiams[l]){
				if((in(v, x.s) || in(v, x.e)) && v != par[0][l]) continue;
				new_diam = max(new_diam, (int)d);
				break;
			}
			maxPath = max(maxPath, new_diam - 3 + plen);
		}
		// TODO: qn.
		vector<int> valup, valdown;
		if(x.s != l) valup.push_back(far[x.s]);
		if(x.e != l) valdown.push_back(far[x.e]);
		for(int i = x.s; dep[i] >= dep[l] + 2; i = par[0][i]) valup.push_back(g[i]);
		for(int i = x.e; dep[i] >= dep[l] + 2; i = par[0][i]) valdown.push_back(g[i]);
		{
			int dist = 0;
			for(auto &[d, v] : fars[l]){
				if((in(v, x.s) || in(v, x.e)) && v != par[0][l]) continue;
				dist = max(dist, (int)d + 1);
				break;
			}
			valup.push_back(dist);
		}
		vector<int> val;
		{
			reverse(all(valdown));
			for(auto &i : valup) val.push_back(i);
			for(auto &i : valdown) val.push_back(i);
		}
		int pmax = -1e9;
		for(int i = 0; i < sz(val); i++){
			maxPath = max(maxPath, sz(val) - 1 - i + val[i] + pmax);
			pmax = max(pmax, i + val[i]);
		}
		ans = min(ans, 2 * n - 4 + x.x - maxPath);
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35788 KB Output is correct
2 Correct 17 ms 35796 KB Output is correct
3 Correct 18 ms 35792 KB Output is correct
4 Correct 18 ms 35848 KB Output is correct
5 Correct 19 ms 35836 KB Output is correct
6 Correct 18 ms 35788 KB Output is correct
7 Correct 20 ms 35836 KB Output is correct
8 Correct 19 ms 35896 KB Output is correct
9 Correct 17 ms 35808 KB Output is correct
10 Correct 21 ms 35868 KB Output is correct
11 Correct 18 ms 35900 KB Output is correct
12 Correct 19 ms 35812 KB Output is correct
13 Correct 18 ms 35788 KB Output is correct
14 Correct 19 ms 35800 KB Output is correct
15 Correct 17 ms 35824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35788 KB Output is correct
2 Correct 17 ms 35796 KB Output is correct
3 Correct 18 ms 35792 KB Output is correct
4 Correct 18 ms 35848 KB Output is correct
5 Correct 19 ms 35836 KB Output is correct
6 Correct 18 ms 35788 KB Output is correct
7 Correct 20 ms 35836 KB Output is correct
8 Correct 19 ms 35896 KB Output is correct
9 Correct 17 ms 35808 KB Output is correct
10 Correct 21 ms 35868 KB Output is correct
11 Correct 18 ms 35900 KB Output is correct
12 Correct 19 ms 35812 KB Output is correct
13 Correct 18 ms 35788 KB Output is correct
14 Correct 19 ms 35800 KB Output is correct
15 Correct 17 ms 35824 KB Output is correct
16 Correct 17 ms 35904 KB Output is correct
17 Correct 19 ms 35788 KB Output is correct
18 Correct 18 ms 35800 KB Output is correct
19 Correct 18 ms 35788 KB Output is correct
20 Correct 22 ms 35872 KB Output is correct
21 Correct 18 ms 35788 KB Output is correct
22 Correct 23 ms 35868 KB Output is correct
23 Correct 19 ms 35820 KB Output is correct
24 Correct 19 ms 35828 KB Output is correct
25 Correct 18 ms 35916 KB Output is correct
26 Correct 20 ms 35852 KB Output is correct
27 Correct 18 ms 35788 KB Output is correct
28 Correct 18 ms 35904 KB Output is correct
29 Correct 18 ms 35860 KB Output is correct
30 Correct 17 ms 35788 KB Output is correct
31 Correct 19 ms 35784 KB Output is correct
32 Correct 21 ms 35840 KB Output is correct
33 Correct 22 ms 35812 KB Output is correct
34 Correct 21 ms 35820 KB Output is correct
35 Correct 19 ms 35804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1270 ms 38160 KB Output is correct
2 Correct 1255 ms 37944 KB Output is correct
3 Correct 1202 ms 37800 KB Output is correct
4 Correct 1112 ms 37704 KB Output is correct
5 Correct 1081 ms 37636 KB Output is correct
6 Correct 532 ms 37508 KB Output is correct
7 Correct 1282 ms 37860 KB Output is correct
8 Correct 1260 ms 37788 KB Output is correct
9 Correct 1237 ms 37948 KB Output is correct
10 Correct 1173 ms 37724 KB Output is correct
11 Correct 1200 ms 37696 KB Output is correct
12 Correct 1178 ms 37740 KB Output is correct
13 Correct 1121 ms 37832 KB Output is correct
14 Correct 1135 ms 37768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35788 KB Output is correct
2 Correct 17 ms 35796 KB Output is correct
3 Correct 18 ms 35792 KB Output is correct
4 Correct 18 ms 35848 KB Output is correct
5 Correct 19 ms 35836 KB Output is correct
6 Correct 18 ms 35788 KB Output is correct
7 Correct 20 ms 35836 KB Output is correct
8 Correct 19 ms 35896 KB Output is correct
9 Correct 17 ms 35808 KB Output is correct
10 Correct 21 ms 35868 KB Output is correct
11 Correct 18 ms 35900 KB Output is correct
12 Correct 19 ms 35812 KB Output is correct
13 Correct 18 ms 35788 KB Output is correct
14 Correct 19 ms 35800 KB Output is correct
15 Correct 17 ms 35824 KB Output is correct
16 Correct 17 ms 35904 KB Output is correct
17 Correct 19 ms 35788 KB Output is correct
18 Correct 18 ms 35800 KB Output is correct
19 Correct 18 ms 35788 KB Output is correct
20 Correct 22 ms 35872 KB Output is correct
21 Correct 18 ms 35788 KB Output is correct
22 Correct 23 ms 35868 KB Output is correct
23 Correct 19 ms 35820 KB Output is correct
24 Correct 19 ms 35828 KB Output is correct
25 Correct 18 ms 35916 KB Output is correct
26 Correct 20 ms 35852 KB Output is correct
27 Correct 18 ms 35788 KB Output is correct
28 Correct 18 ms 35904 KB Output is correct
29 Correct 18 ms 35860 KB Output is correct
30 Correct 17 ms 35788 KB Output is correct
31 Correct 19 ms 35784 KB Output is correct
32 Correct 21 ms 35840 KB Output is correct
33 Correct 22 ms 35812 KB Output is correct
34 Correct 21 ms 35820 KB Output is correct
35 Correct 19 ms 35804 KB Output is correct
36 Correct 17 ms 35920 KB Output is correct
37 Correct 18 ms 35928 KB Output is correct
38 Correct 18 ms 35944 KB Output is correct
39 Correct 19 ms 35916 KB Output is correct
40 Correct 18 ms 35940 KB Output is correct
41 Correct 16 ms 35916 KB Output is correct
42 Correct 17 ms 35884 KB Output is correct
43 Correct 17 ms 35916 KB Output is correct
44 Correct 16 ms 35916 KB Output is correct
45 Correct 19 ms 35932 KB Output is correct
46 Correct 18 ms 35916 KB Output is correct
47 Correct 21 ms 35868 KB Output is correct
48 Correct 17 ms 35848 KB Output is correct
49 Correct 17 ms 35868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35788 KB Output is correct
2 Correct 17 ms 35796 KB Output is correct
3 Correct 18 ms 35792 KB Output is correct
4 Correct 18 ms 35848 KB Output is correct
5 Correct 19 ms 35836 KB Output is correct
6 Correct 18 ms 35788 KB Output is correct
7 Correct 20 ms 35836 KB Output is correct
8 Correct 19 ms 35896 KB Output is correct
9 Correct 17 ms 35808 KB Output is correct
10 Correct 21 ms 35868 KB Output is correct
11 Correct 18 ms 35900 KB Output is correct
12 Correct 19 ms 35812 KB Output is correct
13 Correct 18 ms 35788 KB Output is correct
14 Correct 19 ms 35800 KB Output is correct
15 Correct 17 ms 35824 KB Output is correct
16 Correct 17 ms 35904 KB Output is correct
17 Correct 19 ms 35788 KB Output is correct
18 Correct 18 ms 35800 KB Output is correct
19 Correct 18 ms 35788 KB Output is correct
20 Correct 22 ms 35872 KB Output is correct
21 Correct 18 ms 35788 KB Output is correct
22 Correct 23 ms 35868 KB Output is correct
23 Correct 19 ms 35820 KB Output is correct
24 Correct 19 ms 35828 KB Output is correct
25 Correct 18 ms 35916 KB Output is correct
26 Correct 20 ms 35852 KB Output is correct
27 Correct 18 ms 35788 KB Output is correct
28 Correct 18 ms 35904 KB Output is correct
29 Correct 18 ms 35860 KB Output is correct
30 Correct 17 ms 35788 KB Output is correct
31 Correct 19 ms 35784 KB Output is correct
32 Correct 21 ms 35840 KB Output is correct
33 Correct 22 ms 35812 KB Output is correct
34 Correct 21 ms 35820 KB Output is correct
35 Correct 19 ms 35804 KB Output is correct
36 Correct 17 ms 35920 KB Output is correct
37 Correct 18 ms 35928 KB Output is correct
38 Correct 18 ms 35944 KB Output is correct
39 Correct 19 ms 35916 KB Output is correct
40 Correct 18 ms 35940 KB Output is correct
41 Correct 16 ms 35916 KB Output is correct
42 Correct 17 ms 35884 KB Output is correct
43 Correct 17 ms 35916 KB Output is correct
44 Correct 16 ms 35916 KB Output is correct
45 Correct 19 ms 35932 KB Output is correct
46 Correct 18 ms 35916 KB Output is correct
47 Correct 21 ms 35868 KB Output is correct
48 Correct 17 ms 35848 KB Output is correct
49 Correct 17 ms 35868 KB Output is correct
50 Correct 31 ms 36084 KB Output is correct
51 Correct 25 ms 36044 KB Output is correct
52 Correct 27 ms 36084 KB Output is correct
53 Correct 24 ms 36036 KB Output is correct
54 Correct 23 ms 35972 KB Output is correct
55 Correct 21 ms 35944 KB Output is correct
56 Correct 24 ms 36056 KB Output is correct
57 Correct 23 ms 36020 KB Output is correct
58 Correct 26 ms 36096 KB Output is correct
59 Correct 24 ms 36044 KB Output is correct
60 Correct 29 ms 36104 KB Output is correct
61 Correct 24 ms 35984 KB Output is correct
62 Correct 24 ms 36044 KB Output is correct
63 Correct 23 ms 36044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35788 KB Output is correct
2 Correct 17 ms 35796 KB Output is correct
3 Correct 18 ms 35792 KB Output is correct
4 Correct 18 ms 35848 KB Output is correct
5 Correct 19 ms 35836 KB Output is correct
6 Correct 18 ms 35788 KB Output is correct
7 Correct 20 ms 35836 KB Output is correct
8 Correct 19 ms 35896 KB Output is correct
9 Correct 17 ms 35808 KB Output is correct
10 Correct 21 ms 35868 KB Output is correct
11 Correct 18 ms 35900 KB Output is correct
12 Correct 19 ms 35812 KB Output is correct
13 Correct 18 ms 35788 KB Output is correct
14 Correct 19 ms 35800 KB Output is correct
15 Correct 17 ms 35824 KB Output is correct
16 Correct 17 ms 35904 KB Output is correct
17 Correct 19 ms 35788 KB Output is correct
18 Correct 18 ms 35800 KB Output is correct
19 Correct 18 ms 35788 KB Output is correct
20 Correct 22 ms 35872 KB Output is correct
21 Correct 18 ms 35788 KB Output is correct
22 Correct 23 ms 35868 KB Output is correct
23 Correct 19 ms 35820 KB Output is correct
24 Correct 19 ms 35828 KB Output is correct
25 Correct 18 ms 35916 KB Output is correct
26 Correct 20 ms 35852 KB Output is correct
27 Correct 18 ms 35788 KB Output is correct
28 Correct 18 ms 35904 KB Output is correct
29 Correct 18 ms 35860 KB Output is correct
30 Correct 17 ms 35788 KB Output is correct
31 Correct 19 ms 35784 KB Output is correct
32 Correct 21 ms 35840 KB Output is correct
33 Correct 22 ms 35812 KB Output is correct
34 Correct 21 ms 35820 KB Output is correct
35 Correct 19 ms 35804 KB Output is correct
36 Correct 1270 ms 38160 KB Output is correct
37 Correct 1255 ms 37944 KB Output is correct
38 Correct 1202 ms 37800 KB Output is correct
39 Correct 1112 ms 37704 KB Output is correct
40 Correct 1081 ms 37636 KB Output is correct
41 Correct 532 ms 37508 KB Output is correct
42 Correct 1282 ms 37860 KB Output is correct
43 Correct 1260 ms 37788 KB Output is correct
44 Correct 1237 ms 37948 KB Output is correct
45 Correct 1173 ms 37724 KB Output is correct
46 Correct 1200 ms 37696 KB Output is correct
47 Correct 1178 ms 37740 KB Output is correct
48 Correct 1121 ms 37832 KB Output is correct
49 Correct 1135 ms 37768 KB Output is correct
50 Correct 17 ms 35920 KB Output is correct
51 Correct 18 ms 35928 KB Output is correct
52 Correct 18 ms 35944 KB Output is correct
53 Correct 19 ms 35916 KB Output is correct
54 Correct 18 ms 35940 KB Output is correct
55 Correct 16 ms 35916 KB Output is correct
56 Correct 17 ms 35884 KB Output is correct
57 Correct 17 ms 35916 KB Output is correct
58 Correct 16 ms 35916 KB Output is correct
59 Correct 19 ms 35932 KB Output is correct
60 Correct 18 ms 35916 KB Output is correct
61 Correct 21 ms 35868 KB Output is correct
62 Correct 17 ms 35848 KB Output is correct
63 Correct 17 ms 35868 KB Output is correct
64 Correct 31 ms 36084 KB Output is correct
65 Correct 25 ms 36044 KB Output is correct
66 Correct 27 ms 36084 KB Output is correct
67 Correct 24 ms 36036 KB Output is correct
68 Correct 23 ms 35972 KB Output is correct
69 Correct 21 ms 35944 KB Output is correct
70 Correct 24 ms 36056 KB Output is correct
71 Correct 23 ms 36020 KB Output is correct
72 Correct 26 ms 36096 KB Output is correct
73 Correct 24 ms 36044 KB Output is correct
74 Correct 29 ms 36104 KB Output is correct
75 Correct 24 ms 35984 KB Output is correct
76 Correct 24 ms 36044 KB Output is correct
77 Correct 23 ms 36044 KB Output is correct
78 Correct 1200 ms 37856 KB Output is correct
79 Correct 1257 ms 37848 KB Output is correct
80 Correct 1199 ms 37696 KB Output is correct
81 Correct 1160 ms 37696 KB Output is correct
82 Correct 1092 ms 37688 KB Output is correct
83 Correct 503 ms 37500 KB Output is correct
84 Correct 1236 ms 37956 KB Output is correct
85 Correct 1315 ms 37968 KB Output is correct
86 Correct 1178 ms 37928 KB Output is correct
87 Correct 1170 ms 37732 KB Output is correct
88 Correct 1167 ms 37752 KB Output is correct
89 Correct 1123 ms 37928 KB Output is correct
90 Correct 1057 ms 37600 KB Output is correct
91 Correct 1016 ms 37736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35788 KB Output is correct
2 Correct 17 ms 35796 KB Output is correct
3 Correct 18 ms 35792 KB Output is correct
4 Correct 18 ms 35848 KB Output is correct
5 Correct 19 ms 35836 KB Output is correct
6 Correct 18 ms 35788 KB Output is correct
7 Correct 20 ms 35836 KB Output is correct
8 Correct 19 ms 35896 KB Output is correct
9 Correct 17 ms 35808 KB Output is correct
10 Correct 21 ms 35868 KB Output is correct
11 Correct 18 ms 35900 KB Output is correct
12 Correct 19 ms 35812 KB Output is correct
13 Correct 18 ms 35788 KB Output is correct
14 Correct 19 ms 35800 KB Output is correct
15 Correct 17 ms 35824 KB Output is correct
16 Correct 17 ms 35904 KB Output is correct
17 Correct 19 ms 35788 KB Output is correct
18 Correct 18 ms 35800 KB Output is correct
19 Correct 18 ms 35788 KB Output is correct
20 Correct 22 ms 35872 KB Output is correct
21 Correct 18 ms 35788 KB Output is correct
22 Correct 23 ms 35868 KB Output is correct
23 Correct 19 ms 35820 KB Output is correct
24 Correct 19 ms 35828 KB Output is correct
25 Correct 18 ms 35916 KB Output is correct
26 Correct 20 ms 35852 KB Output is correct
27 Correct 18 ms 35788 KB Output is correct
28 Correct 18 ms 35904 KB Output is correct
29 Correct 18 ms 35860 KB Output is correct
30 Correct 17 ms 35788 KB Output is correct
31 Correct 19 ms 35784 KB Output is correct
32 Correct 21 ms 35840 KB Output is correct
33 Correct 22 ms 35812 KB Output is correct
34 Correct 21 ms 35820 KB Output is correct
35 Correct 19 ms 35804 KB Output is correct
36 Correct 1270 ms 38160 KB Output is correct
37 Correct 1255 ms 37944 KB Output is correct
38 Correct 1202 ms 37800 KB Output is correct
39 Correct 1112 ms 37704 KB Output is correct
40 Correct 1081 ms 37636 KB Output is correct
41 Correct 532 ms 37508 KB Output is correct
42 Correct 1282 ms 37860 KB Output is correct
43 Correct 1260 ms 37788 KB Output is correct
44 Correct 1237 ms 37948 KB Output is correct
45 Correct 1173 ms 37724 KB Output is correct
46 Correct 1200 ms 37696 KB Output is correct
47 Correct 1178 ms 37740 KB Output is correct
48 Correct 1121 ms 37832 KB Output is correct
49 Correct 1135 ms 37768 KB Output is correct
50 Correct 17 ms 35920 KB Output is correct
51 Correct 18 ms 35928 KB Output is correct
52 Correct 18 ms 35944 KB Output is correct
53 Correct 19 ms 35916 KB Output is correct
54 Correct 18 ms 35940 KB Output is correct
55 Correct 16 ms 35916 KB Output is correct
56 Correct 17 ms 35884 KB Output is correct
57 Correct 17 ms 35916 KB Output is correct
58 Correct 16 ms 35916 KB Output is correct
59 Correct 19 ms 35932 KB Output is correct
60 Correct 18 ms 35916 KB Output is correct
61 Correct 21 ms 35868 KB Output is correct
62 Correct 17 ms 35848 KB Output is correct
63 Correct 17 ms 35868 KB Output is correct
64 Correct 31 ms 36084 KB Output is correct
65 Correct 25 ms 36044 KB Output is correct
66 Correct 27 ms 36084 KB Output is correct
67 Correct 24 ms 36036 KB Output is correct
68 Correct 23 ms 35972 KB Output is correct
69 Correct 21 ms 35944 KB Output is correct
70 Correct 24 ms 36056 KB Output is correct
71 Correct 23 ms 36020 KB Output is correct
72 Correct 26 ms 36096 KB Output is correct
73 Correct 24 ms 36044 KB Output is correct
74 Correct 29 ms 36104 KB Output is correct
75 Correct 24 ms 35984 KB Output is correct
76 Correct 24 ms 36044 KB Output is correct
77 Correct 23 ms 36044 KB Output is correct
78 Correct 1200 ms 37856 KB Output is correct
79 Correct 1257 ms 37848 KB Output is correct
80 Correct 1199 ms 37696 KB Output is correct
81 Correct 1160 ms 37696 KB Output is correct
82 Correct 1092 ms 37688 KB Output is correct
83 Correct 503 ms 37500 KB Output is correct
84 Correct 1236 ms 37956 KB Output is correct
85 Correct 1315 ms 37968 KB Output is correct
86 Correct 1178 ms 37928 KB Output is correct
87 Correct 1170 ms 37732 KB Output is correct
88 Correct 1167 ms 37752 KB Output is correct
89 Correct 1123 ms 37928 KB Output is correct
90 Correct 1057 ms 37600 KB Output is correct
91 Correct 1016 ms 37736 KB Output is correct
92 Execution timed out 7050 ms 50292 KB Time limit exceeded
93 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35788 KB Output is correct
2 Correct 17 ms 35796 KB Output is correct
3 Correct 18 ms 35792 KB Output is correct
4 Correct 18 ms 35848 KB Output is correct
5 Correct 19 ms 35836 KB Output is correct
6 Correct 18 ms 35788 KB Output is correct
7 Correct 20 ms 35836 KB Output is correct
8 Correct 19 ms 35896 KB Output is correct
9 Correct 17 ms 35808 KB Output is correct
10 Correct 21 ms 35868 KB Output is correct
11 Correct 18 ms 35900 KB Output is correct
12 Correct 19 ms 35812 KB Output is correct
13 Correct 18 ms 35788 KB Output is correct
14 Correct 19 ms 35800 KB Output is correct
15 Correct 17 ms 35824 KB Output is correct
16 Correct 17 ms 35904 KB Output is correct
17 Correct 19 ms 35788 KB Output is correct
18 Correct 18 ms 35800 KB Output is correct
19 Correct 18 ms 35788 KB Output is correct
20 Correct 22 ms 35872 KB Output is correct
21 Correct 18 ms 35788 KB Output is correct
22 Correct 23 ms 35868 KB Output is correct
23 Correct 19 ms 35820 KB Output is correct
24 Correct 19 ms 35828 KB Output is correct
25 Correct 18 ms 35916 KB Output is correct
26 Correct 20 ms 35852 KB Output is correct
27 Correct 18 ms 35788 KB Output is correct
28 Correct 18 ms 35904 KB Output is correct
29 Correct 18 ms 35860 KB Output is correct
30 Correct 17 ms 35788 KB Output is correct
31 Correct 19 ms 35784 KB Output is correct
32 Correct 21 ms 35840 KB Output is correct
33 Correct 22 ms 35812 KB Output is correct
34 Correct 21 ms 35820 KB Output is correct
35 Correct 19 ms 35804 KB Output is correct
36 Correct 1270 ms 38160 KB Output is correct
37 Correct 1255 ms 37944 KB Output is correct
38 Correct 1202 ms 37800 KB Output is correct
39 Correct 1112 ms 37704 KB Output is correct
40 Correct 1081 ms 37636 KB Output is correct
41 Correct 532 ms 37508 KB Output is correct
42 Correct 1282 ms 37860 KB Output is correct
43 Correct 1260 ms 37788 KB Output is correct
44 Correct 1237 ms 37948 KB Output is correct
45 Correct 1173 ms 37724 KB Output is correct
46 Correct 1200 ms 37696 KB Output is correct
47 Correct 1178 ms 37740 KB Output is correct
48 Correct 1121 ms 37832 KB Output is correct
49 Correct 1135 ms 37768 KB Output is correct
50 Correct 17 ms 35920 KB Output is correct
51 Correct 18 ms 35928 KB Output is correct
52 Correct 18 ms 35944 KB Output is correct
53 Correct 19 ms 35916 KB Output is correct
54 Correct 18 ms 35940 KB Output is correct
55 Correct 16 ms 35916 KB Output is correct
56 Correct 17 ms 35884 KB Output is correct
57 Correct 17 ms 35916 KB Output is correct
58 Correct 16 ms 35916 KB Output is correct
59 Correct 19 ms 35932 KB Output is correct
60 Correct 18 ms 35916 KB Output is correct
61 Correct 21 ms 35868 KB Output is correct
62 Correct 17 ms 35848 KB Output is correct
63 Correct 17 ms 35868 KB Output is correct
64 Correct 31 ms 36084 KB Output is correct
65 Correct 25 ms 36044 KB Output is correct
66 Correct 27 ms 36084 KB Output is correct
67 Correct 24 ms 36036 KB Output is correct
68 Correct 23 ms 35972 KB Output is correct
69 Correct 21 ms 35944 KB Output is correct
70 Correct 24 ms 36056 KB Output is correct
71 Correct 23 ms 36020 KB Output is correct
72 Correct 26 ms 36096 KB Output is correct
73 Correct 24 ms 36044 KB Output is correct
74 Correct 29 ms 36104 KB Output is correct
75 Correct 24 ms 35984 KB Output is correct
76 Correct 24 ms 36044 KB Output is correct
77 Correct 23 ms 36044 KB Output is correct
78 Correct 1200 ms 37856 KB Output is correct
79 Correct 1257 ms 37848 KB Output is correct
80 Correct 1199 ms 37696 KB Output is correct
81 Correct 1160 ms 37696 KB Output is correct
82 Correct 1092 ms 37688 KB Output is correct
83 Correct 503 ms 37500 KB Output is correct
84 Correct 1236 ms 37956 KB Output is correct
85 Correct 1315 ms 37968 KB Output is correct
86 Correct 1178 ms 37928 KB Output is correct
87 Correct 1170 ms 37732 KB Output is correct
88 Correct 1167 ms 37752 KB Output is correct
89 Correct 1123 ms 37928 KB Output is correct
90 Correct 1057 ms 37600 KB Output is correct
91 Correct 1016 ms 37736 KB Output is correct
92 Execution timed out 7050 ms 50292 KB Time limit exceeded
93 Halted 0 ms 0 KB -