#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<int, int> 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;
}
struct node{
int lmax, rmax, opt, len;
node():
lmax(-1e9), rmax(-1e9), opt(-1e9), len(0) {}
node(int x):
lmax(x), rmax(x), opt(-1e9), len(1) {}
node(int a, int b, int c, int e):
lmax(a), rmax(b), opt(c), len(e) {}
node reverse(){
return node(rmax, lmax, opt, len);
}
node operator+(const node &n)const{
return node(
max(lmax - n.len, n.lmax),
max(rmax, n.rmax - len),
max({opt, n.opt, lmax + n.rmax - 1}),
len + n.len);
};
};
vector<int> ord;
int din[MAXN], dout[MAXN], piv;
int far[MAXN], diam[MAXN], pfar[MAXN], pdiam[MAXN];
int f[20][MAXN];
node g[20][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;
}
node gPathSum(int x, int v){
node gs;
for(int i = 0; v; i++){
if(v & 1){
gs = gs + g[i][x];
x = par[i][x];
}
v >>= 1;
}
return gs;
}
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]];
}
}
{
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]));
}
for(auto &i : ord){
if(i == 0) continue;
for(auto &[d, v] : subDiams[par[0][i]]){
if(v == i) continue;
pdiam[i] = max(pdiam[i], (int)d);
break;
}
{
int new_diam = 0;
int cnt = 0;
for(auto &[d, v] : fars[par[0][i]]){
if(v == i) continue;
new_diam += d + 1;
cnt += 1;
if(cnt == 2) break;
}
pdiam[i] = max(pdiam[i], new_diam);
}
for(auto &j : gph[i]){
if(j == par[0][i]) subDiams[i].emplace_back(pdiam[i], j);
else subDiams[i].emplace_back(diam[j], j);
}
sort(all(subDiams[i]));
reverse(all(subDiams[i]));
}
for(int i = 0; i < n; i++){
if(dep[i] >= 2){
int cnt = 0;
int gi = 0;
for(auto &[d, v] : fars[par[0][i]]){
if(v == i || v == par[1][i]) continue;
gi = max(gi, (int)d + 1);
f[0][i] += d + 1;
cnt++;
if(cnt == 2) break;
}
for(auto &[d, v] : subDiams[par[0][i]]){
if(v == i || v == par[1][i]) continue;
f[0][i] = max(f[0][i], (int)d);
break;
}
g[0][i] = node(gi);
}
}
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]]);
g[i][j] = g[i-1][j] + g[i-1][par[i-1][j]];
}
}
}
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.
node valup, valdown;
if(x.s != l) valup = valup + node(far[x.s]);
if(x.e != l) valdown = valdown + node(far[x.e]);
if(dep[x.s] >= dep[l] + 2){
valup = valup + gPathSum(x.s, dep[x.s] - dep[l] - 1);
}
if(dep[x.e] >= dep[l] + 2){
valdown = valdown + gPathSum(x.e, dep[x.e] - dep[l] - 1);
}
{
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 = valup + node(dist);
}
node val = valup + valdown.reverse();
maxPath = max(maxPath, val.opt + val.len - 1);
ans = min(ans, 2 * n - 4 + x.x - maxPath);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
192416 KB |
Output is correct |
2 |
Correct |
86 ms |
192320 KB |
Output is correct |
3 |
Correct |
88 ms |
192408 KB |
Output is correct |
4 |
Correct |
83 ms |
192416 KB |
Output is correct |
5 |
Correct |
82 ms |
192372 KB |
Output is correct |
6 |
Correct |
82 ms |
192372 KB |
Output is correct |
7 |
Correct |
82 ms |
192416 KB |
Output is correct |
8 |
Correct |
82 ms |
192364 KB |
Output is correct |
9 |
Correct |
81 ms |
192400 KB |
Output is correct |
10 |
Correct |
82 ms |
192360 KB |
Output is correct |
11 |
Correct |
82 ms |
192396 KB |
Output is correct |
12 |
Correct |
85 ms |
192324 KB |
Output is correct |
13 |
Correct |
102 ms |
192404 KB |
Output is correct |
14 |
Correct |
83 ms |
192380 KB |
Output is correct |
15 |
Correct |
83 ms |
192388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
192416 KB |
Output is correct |
2 |
Correct |
86 ms |
192320 KB |
Output is correct |
3 |
Correct |
88 ms |
192408 KB |
Output is correct |
4 |
Correct |
83 ms |
192416 KB |
Output is correct |
5 |
Correct |
82 ms |
192372 KB |
Output is correct |
6 |
Correct |
82 ms |
192372 KB |
Output is correct |
7 |
Correct |
82 ms |
192416 KB |
Output is correct |
8 |
Correct |
82 ms |
192364 KB |
Output is correct |
9 |
Correct |
81 ms |
192400 KB |
Output is correct |
10 |
Correct |
82 ms |
192360 KB |
Output is correct |
11 |
Correct |
82 ms |
192396 KB |
Output is correct |
12 |
Correct |
85 ms |
192324 KB |
Output is correct |
13 |
Correct |
102 ms |
192404 KB |
Output is correct |
14 |
Correct |
83 ms |
192380 KB |
Output is correct |
15 |
Correct |
83 ms |
192388 KB |
Output is correct |
16 |
Correct |
84 ms |
192324 KB |
Output is correct |
17 |
Correct |
82 ms |
192428 KB |
Output is correct |
18 |
Correct |
85 ms |
192328 KB |
Output is correct |
19 |
Correct |
85 ms |
192368 KB |
Output is correct |
20 |
Correct |
81 ms |
192416 KB |
Output is correct |
21 |
Correct |
82 ms |
192380 KB |
Output is correct |
22 |
Correct |
82 ms |
192328 KB |
Output is correct |
23 |
Correct |
81 ms |
192364 KB |
Output is correct |
24 |
Correct |
85 ms |
192452 KB |
Output is correct |
25 |
Correct |
82 ms |
192332 KB |
Output is correct |
26 |
Correct |
87 ms |
192424 KB |
Output is correct |
27 |
Correct |
82 ms |
192392 KB |
Output is correct |
28 |
Correct |
87 ms |
192364 KB |
Output is correct |
29 |
Correct |
81 ms |
192384 KB |
Output is correct |
30 |
Correct |
82 ms |
192428 KB |
Output is correct |
31 |
Correct |
84 ms |
192328 KB |
Output is correct |
32 |
Correct |
82 ms |
192360 KB |
Output is correct |
33 |
Correct |
82 ms |
192324 KB |
Output is correct |
34 |
Correct |
81 ms |
192328 KB |
Output is correct |
35 |
Correct |
82 ms |
192324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
194116 KB |
Output is correct |
2 |
Correct |
92 ms |
194168 KB |
Output is correct |
3 |
Correct |
90 ms |
193988 KB |
Output is correct |
4 |
Correct |
91 ms |
194020 KB |
Output is correct |
5 |
Correct |
90 ms |
193888 KB |
Output is correct |
6 |
Correct |
93 ms |
193996 KB |
Output is correct |
7 |
Correct |
89 ms |
194072 KB |
Output is correct |
8 |
Correct |
92 ms |
194116 KB |
Output is correct |
9 |
Correct |
89 ms |
194176 KB |
Output is correct |
10 |
Correct |
90 ms |
193920 KB |
Output is correct |
11 |
Correct |
98 ms |
194128 KB |
Output is correct |
12 |
Correct |
94 ms |
193940 KB |
Output is correct |
13 |
Correct |
95 ms |
193988 KB |
Output is correct |
14 |
Correct |
91 ms |
194048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
192416 KB |
Output is correct |
2 |
Correct |
86 ms |
192320 KB |
Output is correct |
3 |
Correct |
88 ms |
192408 KB |
Output is correct |
4 |
Correct |
83 ms |
192416 KB |
Output is correct |
5 |
Correct |
82 ms |
192372 KB |
Output is correct |
6 |
Correct |
82 ms |
192372 KB |
Output is correct |
7 |
Correct |
82 ms |
192416 KB |
Output is correct |
8 |
Correct |
82 ms |
192364 KB |
Output is correct |
9 |
Correct |
81 ms |
192400 KB |
Output is correct |
10 |
Correct |
82 ms |
192360 KB |
Output is correct |
11 |
Correct |
82 ms |
192396 KB |
Output is correct |
12 |
Correct |
85 ms |
192324 KB |
Output is correct |
13 |
Correct |
102 ms |
192404 KB |
Output is correct |
14 |
Correct |
83 ms |
192380 KB |
Output is correct |
15 |
Correct |
83 ms |
192388 KB |
Output is correct |
16 |
Correct |
84 ms |
192324 KB |
Output is correct |
17 |
Correct |
82 ms |
192428 KB |
Output is correct |
18 |
Correct |
85 ms |
192328 KB |
Output is correct |
19 |
Correct |
85 ms |
192368 KB |
Output is correct |
20 |
Correct |
81 ms |
192416 KB |
Output is correct |
21 |
Correct |
82 ms |
192380 KB |
Output is correct |
22 |
Correct |
82 ms |
192328 KB |
Output is correct |
23 |
Correct |
81 ms |
192364 KB |
Output is correct |
24 |
Correct |
85 ms |
192452 KB |
Output is correct |
25 |
Correct |
82 ms |
192332 KB |
Output is correct |
26 |
Correct |
87 ms |
192424 KB |
Output is correct |
27 |
Correct |
82 ms |
192392 KB |
Output is correct |
28 |
Correct |
87 ms |
192364 KB |
Output is correct |
29 |
Correct |
81 ms |
192384 KB |
Output is correct |
30 |
Correct |
82 ms |
192428 KB |
Output is correct |
31 |
Correct |
84 ms |
192328 KB |
Output is correct |
32 |
Correct |
82 ms |
192360 KB |
Output is correct |
33 |
Correct |
82 ms |
192324 KB |
Output is correct |
34 |
Correct |
81 ms |
192328 KB |
Output is correct |
35 |
Correct |
82 ms |
192324 KB |
Output is correct |
36 |
Correct |
82 ms |
192428 KB |
Output is correct |
37 |
Correct |
82 ms |
192420 KB |
Output is correct |
38 |
Correct |
85 ms |
192512 KB |
Output is correct |
39 |
Correct |
82 ms |
192452 KB |
Output is correct |
40 |
Correct |
84 ms |
192392 KB |
Output is correct |
41 |
Correct |
82 ms |
192492 KB |
Output is correct |
42 |
Correct |
83 ms |
192408 KB |
Output is correct |
43 |
Correct |
82 ms |
192464 KB |
Output is correct |
44 |
Correct |
91 ms |
192548 KB |
Output is correct |
45 |
Correct |
89 ms |
192440 KB |
Output is correct |
46 |
Correct |
82 ms |
192392 KB |
Output is correct |
47 |
Correct |
82 ms |
192400 KB |
Output is correct |
48 |
Correct |
84 ms |
192368 KB |
Output is correct |
49 |
Correct |
89 ms |
192512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
192416 KB |
Output is correct |
2 |
Correct |
86 ms |
192320 KB |
Output is correct |
3 |
Correct |
88 ms |
192408 KB |
Output is correct |
4 |
Correct |
83 ms |
192416 KB |
Output is correct |
5 |
Correct |
82 ms |
192372 KB |
Output is correct |
6 |
Correct |
82 ms |
192372 KB |
Output is correct |
7 |
Correct |
82 ms |
192416 KB |
Output is correct |
8 |
Correct |
82 ms |
192364 KB |
Output is correct |
9 |
Correct |
81 ms |
192400 KB |
Output is correct |
10 |
Correct |
82 ms |
192360 KB |
Output is correct |
11 |
Correct |
82 ms |
192396 KB |
Output is correct |
12 |
Correct |
85 ms |
192324 KB |
Output is correct |
13 |
Correct |
102 ms |
192404 KB |
Output is correct |
14 |
Correct |
83 ms |
192380 KB |
Output is correct |
15 |
Correct |
83 ms |
192388 KB |
Output is correct |
16 |
Correct |
84 ms |
192324 KB |
Output is correct |
17 |
Correct |
82 ms |
192428 KB |
Output is correct |
18 |
Correct |
85 ms |
192328 KB |
Output is correct |
19 |
Correct |
85 ms |
192368 KB |
Output is correct |
20 |
Correct |
81 ms |
192416 KB |
Output is correct |
21 |
Correct |
82 ms |
192380 KB |
Output is correct |
22 |
Correct |
82 ms |
192328 KB |
Output is correct |
23 |
Correct |
81 ms |
192364 KB |
Output is correct |
24 |
Correct |
85 ms |
192452 KB |
Output is correct |
25 |
Correct |
82 ms |
192332 KB |
Output is correct |
26 |
Correct |
87 ms |
192424 KB |
Output is correct |
27 |
Correct |
82 ms |
192392 KB |
Output is correct |
28 |
Correct |
87 ms |
192364 KB |
Output is correct |
29 |
Correct |
81 ms |
192384 KB |
Output is correct |
30 |
Correct |
82 ms |
192428 KB |
Output is correct |
31 |
Correct |
84 ms |
192328 KB |
Output is correct |
32 |
Correct |
82 ms |
192360 KB |
Output is correct |
33 |
Correct |
82 ms |
192324 KB |
Output is correct |
34 |
Correct |
81 ms |
192328 KB |
Output is correct |
35 |
Correct |
82 ms |
192324 KB |
Output is correct |
36 |
Correct |
82 ms |
192428 KB |
Output is correct |
37 |
Correct |
82 ms |
192420 KB |
Output is correct |
38 |
Correct |
85 ms |
192512 KB |
Output is correct |
39 |
Correct |
82 ms |
192452 KB |
Output is correct |
40 |
Correct |
84 ms |
192392 KB |
Output is correct |
41 |
Correct |
82 ms |
192492 KB |
Output is correct |
42 |
Correct |
83 ms |
192408 KB |
Output is correct |
43 |
Correct |
82 ms |
192464 KB |
Output is correct |
44 |
Correct |
91 ms |
192548 KB |
Output is correct |
45 |
Correct |
89 ms |
192440 KB |
Output is correct |
46 |
Correct |
82 ms |
192392 KB |
Output is correct |
47 |
Correct |
82 ms |
192400 KB |
Output is correct |
48 |
Correct |
84 ms |
192368 KB |
Output is correct |
49 |
Correct |
89 ms |
192512 KB |
Output is correct |
50 |
Correct |
83 ms |
192580 KB |
Output is correct |
51 |
Correct |
84 ms |
192616 KB |
Output is correct |
52 |
Correct |
82 ms |
192568 KB |
Output is correct |
53 |
Correct |
82 ms |
192500 KB |
Output is correct |
54 |
Correct |
82 ms |
192508 KB |
Output is correct |
55 |
Correct |
87 ms |
192636 KB |
Output is correct |
56 |
Correct |
85 ms |
192532 KB |
Output is correct |
57 |
Correct |
82 ms |
192604 KB |
Output is correct |
58 |
Correct |
83 ms |
192580 KB |
Output is correct |
59 |
Correct |
87 ms |
192596 KB |
Output is correct |
60 |
Correct |
85 ms |
192536 KB |
Output is correct |
61 |
Correct |
91 ms |
192600 KB |
Output is correct |
62 |
Correct |
82 ms |
192488 KB |
Output is correct |
63 |
Correct |
84 ms |
192536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
192416 KB |
Output is correct |
2 |
Correct |
86 ms |
192320 KB |
Output is correct |
3 |
Correct |
88 ms |
192408 KB |
Output is correct |
4 |
Correct |
83 ms |
192416 KB |
Output is correct |
5 |
Correct |
82 ms |
192372 KB |
Output is correct |
6 |
Correct |
82 ms |
192372 KB |
Output is correct |
7 |
Correct |
82 ms |
192416 KB |
Output is correct |
8 |
Correct |
82 ms |
192364 KB |
Output is correct |
9 |
Correct |
81 ms |
192400 KB |
Output is correct |
10 |
Correct |
82 ms |
192360 KB |
Output is correct |
11 |
Correct |
82 ms |
192396 KB |
Output is correct |
12 |
Correct |
85 ms |
192324 KB |
Output is correct |
13 |
Correct |
102 ms |
192404 KB |
Output is correct |
14 |
Correct |
83 ms |
192380 KB |
Output is correct |
15 |
Correct |
83 ms |
192388 KB |
Output is correct |
16 |
Correct |
84 ms |
192324 KB |
Output is correct |
17 |
Correct |
82 ms |
192428 KB |
Output is correct |
18 |
Correct |
85 ms |
192328 KB |
Output is correct |
19 |
Correct |
85 ms |
192368 KB |
Output is correct |
20 |
Correct |
81 ms |
192416 KB |
Output is correct |
21 |
Correct |
82 ms |
192380 KB |
Output is correct |
22 |
Correct |
82 ms |
192328 KB |
Output is correct |
23 |
Correct |
81 ms |
192364 KB |
Output is correct |
24 |
Correct |
85 ms |
192452 KB |
Output is correct |
25 |
Correct |
82 ms |
192332 KB |
Output is correct |
26 |
Correct |
87 ms |
192424 KB |
Output is correct |
27 |
Correct |
82 ms |
192392 KB |
Output is correct |
28 |
Correct |
87 ms |
192364 KB |
Output is correct |
29 |
Correct |
81 ms |
192384 KB |
Output is correct |
30 |
Correct |
82 ms |
192428 KB |
Output is correct |
31 |
Correct |
84 ms |
192328 KB |
Output is correct |
32 |
Correct |
82 ms |
192360 KB |
Output is correct |
33 |
Correct |
82 ms |
192324 KB |
Output is correct |
34 |
Correct |
81 ms |
192328 KB |
Output is correct |
35 |
Correct |
82 ms |
192324 KB |
Output is correct |
36 |
Correct |
99 ms |
194116 KB |
Output is correct |
37 |
Correct |
92 ms |
194168 KB |
Output is correct |
38 |
Correct |
90 ms |
193988 KB |
Output is correct |
39 |
Correct |
91 ms |
194020 KB |
Output is correct |
40 |
Correct |
90 ms |
193888 KB |
Output is correct |
41 |
Correct |
93 ms |
193996 KB |
Output is correct |
42 |
Correct |
89 ms |
194072 KB |
Output is correct |
43 |
Correct |
92 ms |
194116 KB |
Output is correct |
44 |
Correct |
89 ms |
194176 KB |
Output is correct |
45 |
Correct |
90 ms |
193920 KB |
Output is correct |
46 |
Correct |
98 ms |
194128 KB |
Output is correct |
47 |
Correct |
94 ms |
193940 KB |
Output is correct |
48 |
Correct |
95 ms |
193988 KB |
Output is correct |
49 |
Correct |
91 ms |
194048 KB |
Output is correct |
50 |
Correct |
82 ms |
192428 KB |
Output is correct |
51 |
Correct |
82 ms |
192420 KB |
Output is correct |
52 |
Correct |
85 ms |
192512 KB |
Output is correct |
53 |
Correct |
82 ms |
192452 KB |
Output is correct |
54 |
Correct |
84 ms |
192392 KB |
Output is correct |
55 |
Correct |
82 ms |
192492 KB |
Output is correct |
56 |
Correct |
83 ms |
192408 KB |
Output is correct |
57 |
Correct |
82 ms |
192464 KB |
Output is correct |
58 |
Correct |
91 ms |
192548 KB |
Output is correct |
59 |
Correct |
89 ms |
192440 KB |
Output is correct |
60 |
Correct |
82 ms |
192392 KB |
Output is correct |
61 |
Correct |
82 ms |
192400 KB |
Output is correct |
62 |
Correct |
84 ms |
192368 KB |
Output is correct |
63 |
Correct |
89 ms |
192512 KB |
Output is correct |
64 |
Correct |
83 ms |
192580 KB |
Output is correct |
65 |
Correct |
84 ms |
192616 KB |
Output is correct |
66 |
Correct |
82 ms |
192568 KB |
Output is correct |
67 |
Correct |
82 ms |
192500 KB |
Output is correct |
68 |
Correct |
82 ms |
192508 KB |
Output is correct |
69 |
Correct |
87 ms |
192636 KB |
Output is correct |
70 |
Correct |
85 ms |
192532 KB |
Output is correct |
71 |
Correct |
82 ms |
192604 KB |
Output is correct |
72 |
Correct |
83 ms |
192580 KB |
Output is correct |
73 |
Correct |
87 ms |
192596 KB |
Output is correct |
74 |
Correct |
85 ms |
192536 KB |
Output is correct |
75 |
Correct |
91 ms |
192600 KB |
Output is correct |
76 |
Correct |
82 ms |
192488 KB |
Output is correct |
77 |
Correct |
84 ms |
192536 KB |
Output is correct |
78 |
Correct |
90 ms |
193988 KB |
Output is correct |
79 |
Correct |
89 ms |
194092 KB |
Output is correct |
80 |
Correct |
91 ms |
194032 KB |
Output is correct |
81 |
Correct |
89 ms |
193976 KB |
Output is correct |
82 |
Correct |
88 ms |
193988 KB |
Output is correct |
83 |
Correct |
86 ms |
193928 KB |
Output is correct |
84 |
Correct |
88 ms |
194096 KB |
Output is correct |
85 |
Correct |
94 ms |
194216 KB |
Output is correct |
86 |
Correct |
89 ms |
194136 KB |
Output is correct |
87 |
Correct |
89 ms |
193996 KB |
Output is correct |
88 |
Correct |
89 ms |
194028 KB |
Output is correct |
89 |
Correct |
90 ms |
193992 KB |
Output is correct |
90 |
Correct |
93 ms |
194044 KB |
Output is correct |
91 |
Correct |
88 ms |
193988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
192416 KB |
Output is correct |
2 |
Correct |
86 ms |
192320 KB |
Output is correct |
3 |
Correct |
88 ms |
192408 KB |
Output is correct |
4 |
Correct |
83 ms |
192416 KB |
Output is correct |
5 |
Correct |
82 ms |
192372 KB |
Output is correct |
6 |
Correct |
82 ms |
192372 KB |
Output is correct |
7 |
Correct |
82 ms |
192416 KB |
Output is correct |
8 |
Correct |
82 ms |
192364 KB |
Output is correct |
9 |
Correct |
81 ms |
192400 KB |
Output is correct |
10 |
Correct |
82 ms |
192360 KB |
Output is correct |
11 |
Correct |
82 ms |
192396 KB |
Output is correct |
12 |
Correct |
85 ms |
192324 KB |
Output is correct |
13 |
Correct |
102 ms |
192404 KB |
Output is correct |
14 |
Correct |
83 ms |
192380 KB |
Output is correct |
15 |
Correct |
83 ms |
192388 KB |
Output is correct |
16 |
Correct |
84 ms |
192324 KB |
Output is correct |
17 |
Correct |
82 ms |
192428 KB |
Output is correct |
18 |
Correct |
85 ms |
192328 KB |
Output is correct |
19 |
Correct |
85 ms |
192368 KB |
Output is correct |
20 |
Correct |
81 ms |
192416 KB |
Output is correct |
21 |
Correct |
82 ms |
192380 KB |
Output is correct |
22 |
Correct |
82 ms |
192328 KB |
Output is correct |
23 |
Correct |
81 ms |
192364 KB |
Output is correct |
24 |
Correct |
85 ms |
192452 KB |
Output is correct |
25 |
Correct |
82 ms |
192332 KB |
Output is correct |
26 |
Correct |
87 ms |
192424 KB |
Output is correct |
27 |
Correct |
82 ms |
192392 KB |
Output is correct |
28 |
Correct |
87 ms |
192364 KB |
Output is correct |
29 |
Correct |
81 ms |
192384 KB |
Output is correct |
30 |
Correct |
82 ms |
192428 KB |
Output is correct |
31 |
Correct |
84 ms |
192328 KB |
Output is correct |
32 |
Correct |
82 ms |
192360 KB |
Output is correct |
33 |
Correct |
82 ms |
192324 KB |
Output is correct |
34 |
Correct |
81 ms |
192328 KB |
Output is correct |
35 |
Correct |
82 ms |
192324 KB |
Output is correct |
36 |
Correct |
99 ms |
194116 KB |
Output is correct |
37 |
Correct |
92 ms |
194168 KB |
Output is correct |
38 |
Correct |
90 ms |
193988 KB |
Output is correct |
39 |
Correct |
91 ms |
194020 KB |
Output is correct |
40 |
Correct |
90 ms |
193888 KB |
Output is correct |
41 |
Correct |
93 ms |
193996 KB |
Output is correct |
42 |
Correct |
89 ms |
194072 KB |
Output is correct |
43 |
Correct |
92 ms |
194116 KB |
Output is correct |
44 |
Correct |
89 ms |
194176 KB |
Output is correct |
45 |
Correct |
90 ms |
193920 KB |
Output is correct |
46 |
Correct |
98 ms |
194128 KB |
Output is correct |
47 |
Correct |
94 ms |
193940 KB |
Output is correct |
48 |
Correct |
95 ms |
193988 KB |
Output is correct |
49 |
Correct |
91 ms |
194048 KB |
Output is correct |
50 |
Correct |
82 ms |
192428 KB |
Output is correct |
51 |
Correct |
82 ms |
192420 KB |
Output is correct |
52 |
Correct |
85 ms |
192512 KB |
Output is correct |
53 |
Correct |
82 ms |
192452 KB |
Output is correct |
54 |
Correct |
84 ms |
192392 KB |
Output is correct |
55 |
Correct |
82 ms |
192492 KB |
Output is correct |
56 |
Correct |
83 ms |
192408 KB |
Output is correct |
57 |
Correct |
82 ms |
192464 KB |
Output is correct |
58 |
Correct |
91 ms |
192548 KB |
Output is correct |
59 |
Correct |
89 ms |
192440 KB |
Output is correct |
60 |
Correct |
82 ms |
192392 KB |
Output is correct |
61 |
Correct |
82 ms |
192400 KB |
Output is correct |
62 |
Correct |
84 ms |
192368 KB |
Output is correct |
63 |
Correct |
89 ms |
192512 KB |
Output is correct |
64 |
Correct |
83 ms |
192580 KB |
Output is correct |
65 |
Correct |
84 ms |
192616 KB |
Output is correct |
66 |
Correct |
82 ms |
192568 KB |
Output is correct |
67 |
Correct |
82 ms |
192500 KB |
Output is correct |
68 |
Correct |
82 ms |
192508 KB |
Output is correct |
69 |
Correct |
87 ms |
192636 KB |
Output is correct |
70 |
Correct |
85 ms |
192532 KB |
Output is correct |
71 |
Correct |
82 ms |
192604 KB |
Output is correct |
72 |
Correct |
83 ms |
192580 KB |
Output is correct |
73 |
Correct |
87 ms |
192596 KB |
Output is correct |
74 |
Correct |
85 ms |
192536 KB |
Output is correct |
75 |
Correct |
91 ms |
192600 KB |
Output is correct |
76 |
Correct |
82 ms |
192488 KB |
Output is correct |
77 |
Correct |
84 ms |
192536 KB |
Output is correct |
78 |
Correct |
90 ms |
193988 KB |
Output is correct |
79 |
Correct |
89 ms |
194092 KB |
Output is correct |
80 |
Correct |
91 ms |
194032 KB |
Output is correct |
81 |
Correct |
89 ms |
193976 KB |
Output is correct |
82 |
Correct |
88 ms |
193988 KB |
Output is correct |
83 |
Correct |
86 ms |
193928 KB |
Output is correct |
84 |
Correct |
88 ms |
194096 KB |
Output is correct |
85 |
Correct |
94 ms |
194216 KB |
Output is correct |
86 |
Correct |
89 ms |
194136 KB |
Output is correct |
87 |
Correct |
89 ms |
193996 KB |
Output is correct |
88 |
Correct |
89 ms |
194028 KB |
Output is correct |
89 |
Correct |
90 ms |
193992 KB |
Output is correct |
90 |
Correct |
93 ms |
194044 KB |
Output is correct |
91 |
Correct |
88 ms |
193988 KB |
Output is correct |
92 |
Correct |
363 ms |
217736 KB |
Output is correct |
93 |
Correct |
370 ms |
217720 KB |
Output is correct |
94 |
Correct |
301 ms |
217004 KB |
Output is correct |
95 |
Correct |
188 ms |
217312 KB |
Output is correct |
96 |
Correct |
209 ms |
217444 KB |
Output is correct |
97 |
Correct |
362 ms |
219352 KB |
Output is correct |
98 |
Correct |
371 ms |
219880 KB |
Output is correct |
99 |
Correct |
343 ms |
217460 KB |
Output is correct |
100 |
Correct |
369 ms |
217944 KB |
Output is correct |
101 |
Correct |
353 ms |
217524 KB |
Output is correct |
102 |
Correct |
221 ms |
216788 KB |
Output is correct |
103 |
Correct |
362 ms |
219276 KB |
Output is correct |
104 |
Correct |
362 ms |
218832 KB |
Output is correct |
105 |
Correct |
373 ms |
219000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
192416 KB |
Output is correct |
2 |
Correct |
86 ms |
192320 KB |
Output is correct |
3 |
Correct |
88 ms |
192408 KB |
Output is correct |
4 |
Correct |
83 ms |
192416 KB |
Output is correct |
5 |
Correct |
82 ms |
192372 KB |
Output is correct |
6 |
Correct |
82 ms |
192372 KB |
Output is correct |
7 |
Correct |
82 ms |
192416 KB |
Output is correct |
8 |
Correct |
82 ms |
192364 KB |
Output is correct |
9 |
Correct |
81 ms |
192400 KB |
Output is correct |
10 |
Correct |
82 ms |
192360 KB |
Output is correct |
11 |
Correct |
82 ms |
192396 KB |
Output is correct |
12 |
Correct |
85 ms |
192324 KB |
Output is correct |
13 |
Correct |
102 ms |
192404 KB |
Output is correct |
14 |
Correct |
83 ms |
192380 KB |
Output is correct |
15 |
Correct |
83 ms |
192388 KB |
Output is correct |
16 |
Correct |
84 ms |
192324 KB |
Output is correct |
17 |
Correct |
82 ms |
192428 KB |
Output is correct |
18 |
Correct |
85 ms |
192328 KB |
Output is correct |
19 |
Correct |
85 ms |
192368 KB |
Output is correct |
20 |
Correct |
81 ms |
192416 KB |
Output is correct |
21 |
Correct |
82 ms |
192380 KB |
Output is correct |
22 |
Correct |
82 ms |
192328 KB |
Output is correct |
23 |
Correct |
81 ms |
192364 KB |
Output is correct |
24 |
Correct |
85 ms |
192452 KB |
Output is correct |
25 |
Correct |
82 ms |
192332 KB |
Output is correct |
26 |
Correct |
87 ms |
192424 KB |
Output is correct |
27 |
Correct |
82 ms |
192392 KB |
Output is correct |
28 |
Correct |
87 ms |
192364 KB |
Output is correct |
29 |
Correct |
81 ms |
192384 KB |
Output is correct |
30 |
Correct |
82 ms |
192428 KB |
Output is correct |
31 |
Correct |
84 ms |
192328 KB |
Output is correct |
32 |
Correct |
82 ms |
192360 KB |
Output is correct |
33 |
Correct |
82 ms |
192324 KB |
Output is correct |
34 |
Correct |
81 ms |
192328 KB |
Output is correct |
35 |
Correct |
82 ms |
192324 KB |
Output is correct |
36 |
Correct |
99 ms |
194116 KB |
Output is correct |
37 |
Correct |
92 ms |
194168 KB |
Output is correct |
38 |
Correct |
90 ms |
193988 KB |
Output is correct |
39 |
Correct |
91 ms |
194020 KB |
Output is correct |
40 |
Correct |
90 ms |
193888 KB |
Output is correct |
41 |
Correct |
93 ms |
193996 KB |
Output is correct |
42 |
Correct |
89 ms |
194072 KB |
Output is correct |
43 |
Correct |
92 ms |
194116 KB |
Output is correct |
44 |
Correct |
89 ms |
194176 KB |
Output is correct |
45 |
Correct |
90 ms |
193920 KB |
Output is correct |
46 |
Correct |
98 ms |
194128 KB |
Output is correct |
47 |
Correct |
94 ms |
193940 KB |
Output is correct |
48 |
Correct |
95 ms |
193988 KB |
Output is correct |
49 |
Correct |
91 ms |
194048 KB |
Output is correct |
50 |
Correct |
82 ms |
192428 KB |
Output is correct |
51 |
Correct |
82 ms |
192420 KB |
Output is correct |
52 |
Correct |
85 ms |
192512 KB |
Output is correct |
53 |
Correct |
82 ms |
192452 KB |
Output is correct |
54 |
Correct |
84 ms |
192392 KB |
Output is correct |
55 |
Correct |
82 ms |
192492 KB |
Output is correct |
56 |
Correct |
83 ms |
192408 KB |
Output is correct |
57 |
Correct |
82 ms |
192464 KB |
Output is correct |
58 |
Correct |
91 ms |
192548 KB |
Output is correct |
59 |
Correct |
89 ms |
192440 KB |
Output is correct |
60 |
Correct |
82 ms |
192392 KB |
Output is correct |
61 |
Correct |
82 ms |
192400 KB |
Output is correct |
62 |
Correct |
84 ms |
192368 KB |
Output is correct |
63 |
Correct |
89 ms |
192512 KB |
Output is correct |
64 |
Correct |
83 ms |
192580 KB |
Output is correct |
65 |
Correct |
84 ms |
192616 KB |
Output is correct |
66 |
Correct |
82 ms |
192568 KB |
Output is correct |
67 |
Correct |
82 ms |
192500 KB |
Output is correct |
68 |
Correct |
82 ms |
192508 KB |
Output is correct |
69 |
Correct |
87 ms |
192636 KB |
Output is correct |
70 |
Correct |
85 ms |
192532 KB |
Output is correct |
71 |
Correct |
82 ms |
192604 KB |
Output is correct |
72 |
Correct |
83 ms |
192580 KB |
Output is correct |
73 |
Correct |
87 ms |
192596 KB |
Output is correct |
74 |
Correct |
85 ms |
192536 KB |
Output is correct |
75 |
Correct |
91 ms |
192600 KB |
Output is correct |
76 |
Correct |
82 ms |
192488 KB |
Output is correct |
77 |
Correct |
84 ms |
192536 KB |
Output is correct |
78 |
Correct |
90 ms |
193988 KB |
Output is correct |
79 |
Correct |
89 ms |
194092 KB |
Output is correct |
80 |
Correct |
91 ms |
194032 KB |
Output is correct |
81 |
Correct |
89 ms |
193976 KB |
Output is correct |
82 |
Correct |
88 ms |
193988 KB |
Output is correct |
83 |
Correct |
86 ms |
193928 KB |
Output is correct |
84 |
Correct |
88 ms |
194096 KB |
Output is correct |
85 |
Correct |
94 ms |
194216 KB |
Output is correct |
86 |
Correct |
89 ms |
194136 KB |
Output is correct |
87 |
Correct |
89 ms |
193996 KB |
Output is correct |
88 |
Correct |
89 ms |
194028 KB |
Output is correct |
89 |
Correct |
90 ms |
193992 KB |
Output is correct |
90 |
Correct |
93 ms |
194044 KB |
Output is correct |
91 |
Correct |
88 ms |
193988 KB |
Output is correct |
92 |
Correct |
363 ms |
217736 KB |
Output is correct |
93 |
Correct |
370 ms |
217720 KB |
Output is correct |
94 |
Correct |
301 ms |
217004 KB |
Output is correct |
95 |
Correct |
188 ms |
217312 KB |
Output is correct |
96 |
Correct |
209 ms |
217444 KB |
Output is correct |
97 |
Correct |
362 ms |
219352 KB |
Output is correct |
98 |
Correct |
371 ms |
219880 KB |
Output is correct |
99 |
Correct |
343 ms |
217460 KB |
Output is correct |
100 |
Correct |
369 ms |
217944 KB |
Output is correct |
101 |
Correct |
353 ms |
217524 KB |
Output is correct |
102 |
Correct |
221 ms |
216788 KB |
Output is correct |
103 |
Correct |
362 ms |
219276 KB |
Output is correct |
104 |
Correct |
362 ms |
218832 KB |
Output is correct |
105 |
Correct |
373 ms |
219000 KB |
Output is correct |
106 |
Execution timed out |
7055 ms |
379744 KB |
Time limit exceeded |
107 |
Halted |
0 ms |
0 KB |
- |