#include "roads.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
//#define int long long
using namespace std;
const int N = 1e5+7;
const int MAXW = 1e9+7;
typedef pair<int,int> pii;
typedef long long ll;
vector<pii> g[N];
int deg[N];
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
struct Treap {
int data, priority;
int mxdata;
array<Treap*, 2> kids;
int subtreeSize;
ll sum;
Treap(int _data);
};
int size(Treap *me) {
return me == NULL ? 0 : me->subtreeSize;
}
int mxdata(Treap *me) {
return me == NULL ? 0 : me->mxdata;
}
ll sum(Treap *me) {
return me == NULL ? 0 : me->sum;
}
void recalc(Treap *me) {
if (me==NULL) return;
me->subtreeSize = 1;
me->sum = me->data;
me->mxdata = me->data;
for (Treap* t:me->kids) if (t != NULL) me->subtreeSize += t->subtreeSize;
for (Treap* t:me->kids) if (t != NULL) me->sum += t->sum;
for (Treap* t:me->kids) if (t != NULL) me->mxdata = (me->mxdata > t->mxdata ? me->mxdata : t->mxdata);
}
Treap* merge(Treap *l, Treap *r) {
if (l==NULL) return r;
if (r==NULL) return l;
if (l->priority < r->priority) {
l->kids[1]=merge(l->kids[1], r);
recalc(l);
return l;
}
else {
r->kids[0]=merge(l, r->kids[0]);
recalc(r);
return r;
}
}
array<Treap*, 2> split(Treap *me, int nInLeft) {
if (me == NULL) return {NULL, NULL};
if (size(me->kids[0])>=nInLeft) {
array<Treap*, 2> leftRes=split(me->kids[0], nInLeft);
me->kids[0]=leftRes[1];
recalc(me);
return {leftRes[0], me};
}
else {
nInLeft = nInLeft - size(me->kids[0]) - 1;
array<Treap*, 2> rightRes = split(me->kids[1], nInLeft);
me->kids[1] = rightRes[0];
recalc(me);
return {me, rightRes[1]};
}
return {NULL, NULL};
}
array<Treap*, 2> split_on_value(Treap *me, ll nInLeft) {
if (me == NULL) return {NULL, NULL};
//prop(me);
if (mxdata(me->kids[0])>nInLeft) {
array<Treap*, 2> leftRes=split_on_value(me->kids[0], nInLeft);
me->kids[0]=leftRes[1];
recalc(me);
return {leftRes[0], me};
}
else if (me->data <= nInLeft) {
array<Treap*, 2> rightRes = split_on_value(me->kids[1], nInLeft);
me->kids[1] = rightRes[0];
recalc(me);
return {me, rightRes[1]};
} else {
array<Treap*, 2> leftRes=split_on_value(me->kids[0], nInLeft);
me->kids[0]=leftRes[1];
recalc(me);
return {leftRes[0], me};
}
return {NULL, NULL};
}
Treap::Treap(int _data) {
kids={NULL, NULL};
this->data = _data;
recalc(this);
this->priority = (int)RNG();
}
pair<int,ll> query2(Treap *&me, int cnt) {
array<Treap*, 2> tmp = split(me,cnt);
pair<int,ll> ret = {size(tmp[0]),sum(tmp[0])};
me = merge(tmp[0],tmp[1]);
return ret;
}
pair<int,ll> query(Treap *&me, ll L,ll R,int cnt) {
array<Treap*, 2> tmp = split_on_value(me,L-1);
array<Treap*, 2> tmp2 = split_on_value(tmp[1],R);
pair<int,ll> ret = query2(tmp2[0], cnt);
tmp[1] = merge(tmp2[0],tmp2[1]);
me = merge(tmp[0],tmp[1]);
return ret;
}
void insert(Treap *&me,int x) {
array<Treap*, 2> tmp = split_on_value(me,x);
Treap* tmp2 = new Treap(x);
tmp[0] = merge(tmp[0],tmp2);
me = merge(tmp[0],tmp[1]);
}
Treap* tr[N];
int k;
bool vis[N];
ll dp[N][2];
void dfs(int u,int p = -1) {
vis[u] = 1;
vector<pii> kids;
dp[u][0] = 0;
for(auto [v,w]:g[u]) {
if (v == p) continue;
dfs(v,u);
kids.pb({v,w});
dp[u][0] += dp[v][0];
}
dp[u][1] = dp[u][0];
sort(kids.begin(),kids.end(),[&](pii u,pii v) {return dp[u.F][1]-dp[u.F][0]+u.S < dp[v.F][1]-dp[v.F][0]+v.S;});
int need = max(0,deg[u]-k);
//dbg(u,need);
int last = -1;
for(auto [v,w]:kids) {
if (dp[v][1]-dp[v][0]+w < 0) {
need = max(need-1,0);
last = dp[v][1]-dp[v][0]+w;
dp[u][0] += dp[v][1]-dp[v][0]+w;
continue;
}
if (need == 0) continue;
auto ret = query(tr[u],last+1,dp[v][1]-dp[v][0]+w,need);
last = dp[v][1]-dp[v][0]+w;
need -= ret.F;
assert(need >= 0);
dp[u][0] += ret.S;
//dbg(u,need,dp[u][0],last+1,w+dp[v][1]-dp[v][0]);
if (need == 0) continue;
need--;
assert(need >= 0);
dp[u][0] += dp[v][1]-dp[v][0]+w;
}
if (need > 0) {
auto ret = query(tr[u],last+1,MAXW,need);
dbg(k,u,ret);
dp[u][0] += ret.S;
}
int need1 = max(0,deg[u]-k-1);
last = -1;
for(auto [v,w]:kids) {
if (dp[v][1]-dp[v][0]+w < 0) {
need1 = max(need1-1,0);
last = dp[v][1]-dp[v][0]+w;
dp[u][1] += dp[v][1]-dp[v][0]+w;
continue;
}
if (need1 == 0) continue;
auto ret = query(tr[u],last+1,dp[v][1]-dp[v][0]+w,need1);
last = dp[v][1]-dp[v][0]+w;
need1 -= ret.F;
assert(need1 >= 0);
dp[u][1] += ret.S;
if (need1 == 0) continue;
need1--;
assert(need1 >= 0);
dp[u][1] += dp[v][1]-dp[v][0]+w;
}
if (need1 > 0) {
auto ret = query(tr[u],last+1,MAXW,need1);
dp[u][1] += ret.S;
}
dbg(k,u,dp[u][0],dp[u][1]);
}
vector<long long> minimum_closure_costs(int N, vector<int> U,
vector<int> V,
vector<int> W) {
for(int i = 0 ; i < N-1 ; i++) {
g[U[i]].pb({V[i],W[i]});
g[V[i]].pb({U[i],W[i]});
deg[U[i]]++;
deg[V[i]]++;
}
vector<int> vec;
for(int i = 0 ; i < N ; i++) {
vec.pb(i);
sort(g[i].begin(),g[i].end(),[&](pii u,pii v) {return deg[u.F] > deg[v.F];});
}
sort(vec.begin(),vec.end(),
[](int u,int v) {return deg[u] < deg[v];});
int ptr = 0;
vector<ll> ans(N,0);
for(k = 0 ; k < N; k++) {
while(ptr < N && deg[vec[ptr]] <= k) ptr++;
dbg(k,ptr);
for(int i = ptr ; i < N ; i++) {
int u = vec[i];
//dbg(k,u);
while(!g[u].empty() && deg[g[u].back().F] <= k) {
int w = g[u].back().S;
g[u].pop_back();
//dbg(query2(tr[u],1));
insert(tr[u],w);
//dbg(query2(tr[u],1));
dbg(k,u,w);
}
}
for(int i = ptr ; i < N ; i++) {
int u = vec[i];
if (!vis[u]) {dfs(u);ans[k] += dp[u][0];}
}
for(int i = ptr ; i < N ; i++) {
int u = vec[i];
vis[u] = 0;
}
}
return ans;
}
Compilation message
roads.cpp: In function 'void dfs(int, int)':
roads.cpp:153:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
153 | for(auto [v,w]:g[u]) {
| ^
roads.cpp:165:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
165 | for(auto [v,w]:kids) {
| ^
roads.cpp:191:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
191 | for(auto [v,w]:kids) {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
4 ms |
2900 KB |
Output is correct |
3 |
Correct |
4 ms |
3028 KB |
Output is correct |
4 |
Correct |
4 ms |
3004 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
1 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
3 ms |
2900 KB |
Output is correct |
9 |
Correct |
4 ms |
2936 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
102 ms |
12620 KB |
Output is correct |
13 |
Correct |
184 ms |
19180 KB |
Output is correct |
14 |
Correct |
201 ms |
17604 KB |
Output is correct |
15 |
Correct |
216 ms |
19204 KB |
Output is correct |
16 |
Correct |
219 ms |
19428 KB |
Output is correct |
17 |
Correct |
158 ms |
19408 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
144 ms |
17612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
52 ms |
23592 KB |
Output is correct |
3 |
Correct |
78 ms |
28196 KB |
Output is correct |
4 |
Correct |
66 ms |
30060 KB |
Output is correct |
5 |
Correct |
65 ms |
30100 KB |
Output is correct |
6 |
Correct |
2 ms |
3028 KB |
Output is correct |
7 |
Correct |
3 ms |
3156 KB |
Output is correct |
8 |
Correct |
2 ms |
3156 KB |
Output is correct |
9 |
Correct |
2 ms |
2660 KB |
Output is correct |
10 |
Correct |
2 ms |
2664 KB |
Output is correct |
11 |
Correct |
2 ms |
2660 KB |
Output is correct |
12 |
Correct |
40 ms |
18672 KB |
Output is correct |
13 |
Correct |
62 ms |
29260 KB |
Output is correct |
14 |
Correct |
1 ms |
2644 KB |
Output is correct |
15 |
Correct |
57 ms |
26636 KB |
Output is correct |
16 |
Correct |
62 ms |
29168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2668 KB |
Output is correct |
6 |
Correct |
2 ms |
2660 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2692 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
1 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2664 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2660 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
1 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2668 KB |
Output is correct |
6 |
Correct |
2 ms |
2660 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
1 ms |
2692 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
1 ms |
2644 KB |
Output is correct |
13 |
Correct |
2 ms |
2644 KB |
Output is correct |
14 |
Correct |
2 ms |
2664 KB |
Output is correct |
15 |
Correct |
2 ms |
2644 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Correct |
1 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2644 KB |
Output is correct |
19 |
Correct |
1 ms |
2660 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
1 ms |
2644 KB |
Output is correct |
22 |
Correct |
1 ms |
2644 KB |
Output is correct |
23 |
Correct |
2 ms |
2772 KB |
Output is correct |
24 |
Correct |
3 ms |
2932 KB |
Output is correct |
25 |
Correct |
3 ms |
2900 KB |
Output is correct |
26 |
Correct |
3 ms |
3028 KB |
Output is correct |
27 |
Correct |
4 ms |
3028 KB |
Output is correct |
28 |
Correct |
4 ms |
3028 KB |
Output is correct |
29 |
Correct |
3 ms |
2900 KB |
Output is correct |
30 |
Correct |
5 ms |
3180 KB |
Output is correct |
31 |
Correct |
4 ms |
3028 KB |
Output is correct |
32 |
Correct |
4 ms |
3028 KB |
Output is correct |
33 |
Correct |
2 ms |
3028 KB |
Output is correct |
34 |
Correct |
3 ms |
3156 KB |
Output is correct |
35 |
Correct |
2 ms |
3156 KB |
Output is correct |
36 |
Correct |
4 ms |
3028 KB |
Output is correct |
37 |
Correct |
5 ms |
3028 KB |
Output is correct |
38 |
Correct |
4 ms |
3060 KB |
Output is correct |
39 |
Correct |
1 ms |
2644 KB |
Output is correct |
40 |
Correct |
1 ms |
2656 KB |
Output is correct |
41 |
Correct |
2 ms |
2644 KB |
Output is correct |
42 |
Correct |
1 ms |
2644 KB |
Output is correct |
43 |
Correct |
1 ms |
2644 KB |
Output is correct |
44 |
Correct |
2 ms |
2660 KB |
Output is correct |
45 |
Correct |
2 ms |
2668 KB |
Output is correct |
46 |
Correct |
2 ms |
2664 KB |
Output is correct |
47 |
Correct |
1 ms |
2644 KB |
Output is correct |
48 |
Correct |
1 ms |
2644 KB |
Output is correct |
49 |
Correct |
2 ms |
2644 KB |
Output is correct |
50 |
Correct |
2 ms |
2644 KB |
Output is correct |
51 |
Correct |
2 ms |
2644 KB |
Output is correct |
52 |
Correct |
3 ms |
2688 KB |
Output is correct |
53 |
Correct |
3 ms |
2928 KB |
Output is correct |
54 |
Correct |
3 ms |
2900 KB |
Output is correct |
55 |
Correct |
4 ms |
2928 KB |
Output is correct |
56 |
Correct |
3 ms |
2900 KB |
Output is correct |
57 |
Correct |
4 ms |
2932 KB |
Output is correct |
58 |
Correct |
1 ms |
2644 KB |
Output is correct |
59 |
Correct |
2 ms |
2644 KB |
Output is correct |
60 |
Correct |
2 ms |
2644 KB |
Output is correct |
61 |
Correct |
2 ms |
2644 KB |
Output is correct |
62 |
Correct |
2 ms |
2644 KB |
Output is correct |
63 |
Correct |
1 ms |
2644 KB |
Output is correct |
64 |
Correct |
3 ms |
2900 KB |
Output is correct |
65 |
Correct |
3 ms |
2900 KB |
Output is correct |
66 |
Correct |
4 ms |
3028 KB |
Output is correct |
67 |
Correct |
3 ms |
3028 KB |
Output is correct |
68 |
Correct |
4 ms |
3028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
17128 KB |
Output is correct |
2 |
Correct |
80 ms |
16920 KB |
Output is correct |
3 |
Correct |
177 ms |
19576 KB |
Output is correct |
4 |
Correct |
85 ms |
17696 KB |
Output is correct |
5 |
Correct |
155 ms |
19612 KB |
Output is correct |
6 |
Correct |
176 ms |
19244 KB |
Output is correct |
7 |
Correct |
125 ms |
18852 KB |
Output is correct |
8 |
Correct |
133 ms |
17952 KB |
Output is correct |
9 |
Correct |
84 ms |
22140 KB |
Output is correct |
10 |
Correct |
118 ms |
17864 KB |
Output is correct |
11 |
Correct |
163 ms |
19420 KB |
Output is correct |
12 |
Correct |
158 ms |
19212 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
56 ms |
25344 KB |
Output is correct |
15 |
Correct |
62 ms |
27904 KB |
Output is correct |
16 |
Correct |
3 ms |
2900 KB |
Output is correct |
17 |
Correct |
2 ms |
2900 KB |
Output is correct |
18 |
Correct |
4 ms |
2900 KB |
Output is correct |
19 |
Correct |
4 ms |
2900 KB |
Output is correct |
20 |
Correct |
3 ms |
2900 KB |
Output is correct |
21 |
Correct |
144 ms |
17616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
17128 KB |
Output is correct |
2 |
Correct |
80 ms |
16920 KB |
Output is correct |
3 |
Correct |
177 ms |
19576 KB |
Output is correct |
4 |
Correct |
85 ms |
17696 KB |
Output is correct |
5 |
Correct |
155 ms |
19612 KB |
Output is correct |
6 |
Correct |
176 ms |
19244 KB |
Output is correct |
7 |
Correct |
125 ms |
18852 KB |
Output is correct |
8 |
Correct |
133 ms |
17952 KB |
Output is correct |
9 |
Correct |
84 ms |
22140 KB |
Output is correct |
10 |
Correct |
118 ms |
17864 KB |
Output is correct |
11 |
Correct |
163 ms |
19420 KB |
Output is correct |
12 |
Correct |
158 ms |
19212 KB |
Output is correct |
13 |
Correct |
1 ms |
2644 KB |
Output is correct |
14 |
Correct |
56 ms |
25344 KB |
Output is correct |
15 |
Correct |
62 ms |
27904 KB |
Output is correct |
16 |
Correct |
3 ms |
2900 KB |
Output is correct |
17 |
Correct |
2 ms |
2900 KB |
Output is correct |
18 |
Correct |
4 ms |
2900 KB |
Output is correct |
19 |
Correct |
4 ms |
2900 KB |
Output is correct |
20 |
Correct |
3 ms |
2900 KB |
Output is correct |
21 |
Correct |
144 ms |
17616 KB |
Output is correct |
22 |
Correct |
1 ms |
2644 KB |
Output is correct |
23 |
Correct |
1 ms |
2644 KB |
Output is correct |
24 |
Correct |
1 ms |
2644 KB |
Output is correct |
25 |
Correct |
73 ms |
15524 KB |
Output is correct |
26 |
Correct |
64 ms |
15332 KB |
Output is correct |
27 |
Correct |
97 ms |
19024 KB |
Output is correct |
28 |
Correct |
197 ms |
21044 KB |
Output is correct |
29 |
Correct |
160 ms |
19532 KB |
Output is correct |
30 |
Correct |
184 ms |
19912 KB |
Output is correct |
31 |
Correct |
200 ms |
20376 KB |
Output is correct |
32 |
Correct |
85 ms |
18284 KB |
Output is correct |
33 |
Correct |
181 ms |
19656 KB |
Output is correct |
34 |
Correct |
143 ms |
20200 KB |
Output is correct |
35 |
Correct |
97 ms |
25320 KB |
Output is correct |
36 |
Correct |
173 ms |
20848 KB |
Output is correct |
37 |
Correct |
191 ms |
20500 KB |
Output is correct |
38 |
Correct |
38 ms |
18640 KB |
Output is correct |
39 |
Correct |
62 ms |
29220 KB |
Output is correct |
40 |
Correct |
3 ms |
2900 KB |
Output is correct |
41 |
Correct |
3 ms |
2900 KB |
Output is correct |
42 |
Correct |
4 ms |
2960 KB |
Output is correct |
43 |
Correct |
3 ms |
2932 KB |
Output is correct |
44 |
Correct |
4 ms |
3028 KB |
Output is correct |
45 |
Correct |
1 ms |
2664 KB |
Output is correct |
46 |
Correct |
2 ms |
2644 KB |
Output is correct |
47 |
Correct |
2 ms |
2644 KB |
Output is correct |
48 |
Correct |
2 ms |
2644 KB |
Output is correct |
49 |
Correct |
1 ms |
2644 KB |
Output is correct |
50 |
Correct |
100 ms |
13208 KB |
Output is correct |
51 |
Correct |
183 ms |
20180 KB |
Output is correct |
52 |
Correct |
82 ms |
18504 KB |
Output is correct |
53 |
Correct |
80 ms |
18200 KB |
Output is correct |
54 |
Correct |
177 ms |
20976 KB |
Output is correct |
55 |
Correct |
84 ms |
18964 KB |
Output is correct |
56 |
Correct |
153 ms |
20924 KB |
Output is correct |
57 |
Correct |
176 ms |
20572 KB |
Output is correct |
58 |
Correct |
126 ms |
20084 KB |
Output is correct |
59 |
Correct |
144 ms |
19212 KB |
Output is correct |
60 |
Correct |
82 ms |
23456 KB |
Output is correct |
61 |
Correct |
90 ms |
19276 KB |
Output is correct |
62 |
Correct |
164 ms |
20804 KB |
Output is correct |
63 |
Correct |
212 ms |
20516 KB |
Output is correct |
64 |
Correct |
1 ms |
2664 KB |
Output is correct |
65 |
Correct |
60 ms |
26556 KB |
Output is correct |
66 |
Correct |
63 ms |
29256 KB |
Output is correct |
67 |
Correct |
3 ms |
2900 KB |
Output is correct |
68 |
Correct |
3 ms |
2928 KB |
Output is correct |
69 |
Correct |
3 ms |
3028 KB |
Output is correct |
70 |
Correct |
3 ms |
3028 KB |
Output is correct |
71 |
Correct |
3 ms |
3028 KB |
Output is correct |
72 |
Correct |
143 ms |
18460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
4 ms |
2900 KB |
Output is correct |
3 |
Correct |
4 ms |
3028 KB |
Output is correct |
4 |
Correct |
4 ms |
3004 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
1 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
3 ms |
2900 KB |
Output is correct |
9 |
Correct |
4 ms |
2936 KB |
Output is correct |
10 |
Correct |
1 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
102 ms |
12620 KB |
Output is correct |
13 |
Correct |
184 ms |
19180 KB |
Output is correct |
14 |
Correct |
201 ms |
17604 KB |
Output is correct |
15 |
Correct |
216 ms |
19204 KB |
Output is correct |
16 |
Correct |
219 ms |
19428 KB |
Output is correct |
17 |
Correct |
158 ms |
19408 KB |
Output is correct |
18 |
Correct |
1 ms |
2644 KB |
Output is correct |
19 |
Correct |
144 ms |
17612 KB |
Output is correct |
20 |
Correct |
2 ms |
2688 KB |
Output is correct |
21 |
Correct |
52 ms |
23592 KB |
Output is correct |
22 |
Correct |
78 ms |
28196 KB |
Output is correct |
23 |
Correct |
66 ms |
30060 KB |
Output is correct |
24 |
Correct |
65 ms |
30100 KB |
Output is correct |
25 |
Correct |
2 ms |
3028 KB |
Output is correct |
26 |
Correct |
3 ms |
3156 KB |
Output is correct |
27 |
Correct |
2 ms |
3156 KB |
Output is correct |
28 |
Correct |
2 ms |
2660 KB |
Output is correct |
29 |
Correct |
2 ms |
2664 KB |
Output is correct |
30 |
Correct |
2 ms |
2660 KB |
Output is correct |
31 |
Correct |
40 ms |
18672 KB |
Output is correct |
32 |
Correct |
62 ms |
29260 KB |
Output is correct |
33 |
Correct |
1 ms |
2644 KB |
Output is correct |
34 |
Correct |
57 ms |
26636 KB |
Output is correct |
35 |
Correct |
62 ms |
29168 KB |
Output is correct |
36 |
Correct |
1 ms |
2644 KB |
Output is correct |
37 |
Correct |
1 ms |
2644 KB |
Output is correct |
38 |
Correct |
1 ms |
2644 KB |
Output is correct |
39 |
Correct |
1 ms |
2644 KB |
Output is correct |
40 |
Correct |
2 ms |
2668 KB |
Output is correct |
41 |
Correct |
2 ms |
2660 KB |
Output is correct |
42 |
Correct |
1 ms |
2644 KB |
Output is correct |
43 |
Correct |
1 ms |
2644 KB |
Output is correct |
44 |
Correct |
1 ms |
2692 KB |
Output is correct |
45 |
Correct |
1 ms |
2644 KB |
Output is correct |
46 |
Correct |
2 ms |
2644 KB |
Output is correct |
47 |
Correct |
1 ms |
2644 KB |
Output is correct |
48 |
Correct |
2 ms |
2644 KB |
Output is correct |
49 |
Correct |
2 ms |
2664 KB |
Output is correct |
50 |
Correct |
2 ms |
2644 KB |
Output is correct |
51 |
Correct |
2 ms |
2644 KB |
Output is correct |
52 |
Correct |
1 ms |
2644 KB |
Output is correct |
53 |
Correct |
2 ms |
2644 KB |
Output is correct |
54 |
Correct |
1 ms |
2660 KB |
Output is correct |
55 |
Correct |
2 ms |
2644 KB |
Output is correct |
56 |
Correct |
1 ms |
2644 KB |
Output is correct |
57 |
Correct |
1 ms |
2644 KB |
Output is correct |
58 |
Correct |
2 ms |
2772 KB |
Output is correct |
59 |
Correct |
3 ms |
2932 KB |
Output is correct |
60 |
Correct |
3 ms |
2900 KB |
Output is correct |
61 |
Correct |
3 ms |
3028 KB |
Output is correct |
62 |
Correct |
4 ms |
3028 KB |
Output is correct |
63 |
Correct |
4 ms |
3028 KB |
Output is correct |
64 |
Correct |
3 ms |
2900 KB |
Output is correct |
65 |
Correct |
5 ms |
3180 KB |
Output is correct |
66 |
Correct |
4 ms |
3028 KB |
Output is correct |
67 |
Correct |
4 ms |
3028 KB |
Output is correct |
68 |
Correct |
2 ms |
3028 KB |
Output is correct |
69 |
Correct |
3 ms |
3156 KB |
Output is correct |
70 |
Correct |
2 ms |
3156 KB |
Output is correct |
71 |
Correct |
4 ms |
3028 KB |
Output is correct |
72 |
Correct |
5 ms |
3028 KB |
Output is correct |
73 |
Correct |
4 ms |
3060 KB |
Output is correct |
74 |
Correct |
1 ms |
2644 KB |
Output is correct |
75 |
Correct |
1 ms |
2656 KB |
Output is correct |
76 |
Correct |
2 ms |
2644 KB |
Output is correct |
77 |
Correct |
1 ms |
2644 KB |
Output is correct |
78 |
Correct |
1 ms |
2644 KB |
Output is correct |
79 |
Correct |
2 ms |
2660 KB |
Output is correct |
80 |
Correct |
2 ms |
2668 KB |
Output is correct |
81 |
Correct |
2 ms |
2664 KB |
Output is correct |
82 |
Correct |
1 ms |
2644 KB |
Output is correct |
83 |
Correct |
1 ms |
2644 KB |
Output is correct |
84 |
Correct |
2 ms |
2644 KB |
Output is correct |
85 |
Correct |
2 ms |
2644 KB |
Output is correct |
86 |
Correct |
2 ms |
2644 KB |
Output is correct |
87 |
Correct |
3 ms |
2688 KB |
Output is correct |
88 |
Correct |
3 ms |
2928 KB |
Output is correct |
89 |
Correct |
3 ms |
2900 KB |
Output is correct |
90 |
Correct |
4 ms |
2928 KB |
Output is correct |
91 |
Correct |
3 ms |
2900 KB |
Output is correct |
92 |
Correct |
4 ms |
2932 KB |
Output is correct |
93 |
Correct |
1 ms |
2644 KB |
Output is correct |
94 |
Correct |
2 ms |
2644 KB |
Output is correct |
95 |
Correct |
2 ms |
2644 KB |
Output is correct |
96 |
Correct |
2 ms |
2644 KB |
Output is correct |
97 |
Correct |
2 ms |
2644 KB |
Output is correct |
98 |
Correct |
1 ms |
2644 KB |
Output is correct |
99 |
Correct |
3 ms |
2900 KB |
Output is correct |
100 |
Correct |
3 ms |
2900 KB |
Output is correct |
101 |
Correct |
4 ms |
3028 KB |
Output is correct |
102 |
Correct |
3 ms |
3028 KB |
Output is correct |
103 |
Correct |
4 ms |
3028 KB |
Output is correct |
104 |
Correct |
81 ms |
17128 KB |
Output is correct |
105 |
Correct |
80 ms |
16920 KB |
Output is correct |
106 |
Correct |
177 ms |
19576 KB |
Output is correct |
107 |
Correct |
85 ms |
17696 KB |
Output is correct |
108 |
Correct |
155 ms |
19612 KB |
Output is correct |
109 |
Correct |
176 ms |
19244 KB |
Output is correct |
110 |
Correct |
125 ms |
18852 KB |
Output is correct |
111 |
Correct |
133 ms |
17952 KB |
Output is correct |
112 |
Correct |
84 ms |
22140 KB |
Output is correct |
113 |
Correct |
118 ms |
17864 KB |
Output is correct |
114 |
Correct |
163 ms |
19420 KB |
Output is correct |
115 |
Correct |
158 ms |
19212 KB |
Output is correct |
116 |
Correct |
1 ms |
2644 KB |
Output is correct |
117 |
Correct |
56 ms |
25344 KB |
Output is correct |
118 |
Correct |
62 ms |
27904 KB |
Output is correct |
119 |
Correct |
3 ms |
2900 KB |
Output is correct |
120 |
Correct |
2 ms |
2900 KB |
Output is correct |
121 |
Correct |
4 ms |
2900 KB |
Output is correct |
122 |
Correct |
4 ms |
2900 KB |
Output is correct |
123 |
Correct |
3 ms |
2900 KB |
Output is correct |
124 |
Correct |
144 ms |
17616 KB |
Output is correct |
125 |
Correct |
1 ms |
2644 KB |
Output is correct |
126 |
Correct |
1 ms |
2644 KB |
Output is correct |
127 |
Correct |
1 ms |
2644 KB |
Output is correct |
128 |
Correct |
73 ms |
15524 KB |
Output is correct |
129 |
Correct |
64 ms |
15332 KB |
Output is correct |
130 |
Correct |
97 ms |
19024 KB |
Output is correct |
131 |
Correct |
197 ms |
21044 KB |
Output is correct |
132 |
Correct |
160 ms |
19532 KB |
Output is correct |
133 |
Correct |
184 ms |
19912 KB |
Output is correct |
134 |
Correct |
200 ms |
20376 KB |
Output is correct |
135 |
Correct |
85 ms |
18284 KB |
Output is correct |
136 |
Correct |
181 ms |
19656 KB |
Output is correct |
137 |
Correct |
143 ms |
20200 KB |
Output is correct |
138 |
Correct |
97 ms |
25320 KB |
Output is correct |
139 |
Correct |
173 ms |
20848 KB |
Output is correct |
140 |
Correct |
191 ms |
20500 KB |
Output is correct |
141 |
Correct |
38 ms |
18640 KB |
Output is correct |
142 |
Correct |
62 ms |
29220 KB |
Output is correct |
143 |
Correct |
3 ms |
2900 KB |
Output is correct |
144 |
Correct |
3 ms |
2900 KB |
Output is correct |
145 |
Correct |
4 ms |
2960 KB |
Output is correct |
146 |
Correct |
3 ms |
2932 KB |
Output is correct |
147 |
Correct |
4 ms |
3028 KB |
Output is correct |
148 |
Correct |
1 ms |
2664 KB |
Output is correct |
149 |
Correct |
2 ms |
2644 KB |
Output is correct |
150 |
Correct |
2 ms |
2644 KB |
Output is correct |
151 |
Correct |
2 ms |
2644 KB |
Output is correct |
152 |
Correct |
1 ms |
2644 KB |
Output is correct |
153 |
Correct |
100 ms |
13208 KB |
Output is correct |
154 |
Correct |
183 ms |
20180 KB |
Output is correct |
155 |
Correct |
82 ms |
18504 KB |
Output is correct |
156 |
Correct |
80 ms |
18200 KB |
Output is correct |
157 |
Correct |
177 ms |
20976 KB |
Output is correct |
158 |
Correct |
84 ms |
18964 KB |
Output is correct |
159 |
Correct |
153 ms |
20924 KB |
Output is correct |
160 |
Correct |
176 ms |
20572 KB |
Output is correct |
161 |
Correct |
126 ms |
20084 KB |
Output is correct |
162 |
Correct |
144 ms |
19212 KB |
Output is correct |
163 |
Correct |
82 ms |
23456 KB |
Output is correct |
164 |
Correct |
90 ms |
19276 KB |
Output is correct |
165 |
Correct |
164 ms |
20804 KB |
Output is correct |
166 |
Correct |
212 ms |
20516 KB |
Output is correct |
167 |
Correct |
1 ms |
2664 KB |
Output is correct |
168 |
Correct |
60 ms |
26556 KB |
Output is correct |
169 |
Correct |
63 ms |
29256 KB |
Output is correct |
170 |
Correct |
3 ms |
2900 KB |
Output is correct |
171 |
Correct |
3 ms |
2928 KB |
Output is correct |
172 |
Correct |
3 ms |
3028 KB |
Output is correct |
173 |
Correct |
3 ms |
3028 KB |
Output is correct |
174 |
Correct |
3 ms |
3028 KB |
Output is correct |
175 |
Correct |
143 ms |
18460 KB |
Output is correct |
176 |
Correct |
2 ms |
2644 KB |
Output is correct |
177 |
Correct |
87 ms |
19532 KB |
Output is correct |
178 |
Correct |
68 ms |
15940 KB |
Output is correct |
179 |
Correct |
173 ms |
21016 KB |
Output is correct |
180 |
Correct |
166 ms |
20644 KB |
Output is correct |
181 |
Correct |
166 ms |
21948 KB |
Output is correct |
182 |
Correct |
173 ms |
21456 KB |
Output is correct |
183 |
Correct |
124 ms |
20240 KB |
Output is correct |
184 |
Correct |
172 ms |
20456 KB |
Output is correct |
185 |
Correct |
190 ms |
20644 KB |
Output is correct |
186 |
Correct |
193 ms |
19928 KB |
Output is correct |
187 |
Correct |
238 ms |
21336 KB |
Output is correct |
188 |
Correct |
92 ms |
18260 KB |
Output is correct |
189 |
Correct |
139 ms |
19216 KB |
Output is correct |
190 |
Correct |
193 ms |
21556 KB |
Output is correct |
191 |
Correct |
173 ms |
20776 KB |
Output is correct |
192 |
Correct |
208 ms |
21316 KB |
Output is correct |
193 |
Correct |
371 ms |
21260 KB |
Output is correct |
194 |
Correct |
184 ms |
22004 KB |
Output is correct |
195 |
Correct |
54 ms |
25440 KB |
Output is correct |
196 |
Correct |
62 ms |
28256 KB |
Output is correct |
197 |
Correct |
64 ms |
30064 KB |
Output is correct |
198 |
Correct |
88 ms |
30064 KB |
Output is correct |
199 |
Correct |
2 ms |
2920 KB |
Output is correct |
200 |
Correct |
3 ms |
3052 KB |
Output is correct |
201 |
Correct |
2 ms |
2900 KB |
Output is correct |
202 |
Correct |
4 ms |
3028 KB |
Output is correct |
203 |
Correct |
4 ms |
2984 KB |
Output is correct |
204 |
Correct |
3 ms |
3028 KB |
Output is correct |
205 |
Correct |
3 ms |
2948 KB |
Output is correct |
206 |
Correct |
4 ms |
3056 KB |
Output is correct |
207 |
Correct |
4 ms |
3028 KB |
Output is correct |
208 |
Correct |
4 ms |
3028 KB |
Output is correct |
209 |
Correct |
3 ms |
3028 KB |
Output is correct |
210 |
Correct |
4 ms |
3156 KB |
Output is correct |
211 |
Correct |
2 ms |
3156 KB |
Output is correct |
212 |
Correct |
4 ms |
3028 KB |
Output is correct |
213 |
Correct |
4 ms |
3028 KB |
Output is correct |
214 |
Correct |
4 ms |
3044 KB |
Output is correct |
215 |
Correct |
2 ms |
2668 KB |
Output is correct |
216 |
Correct |
1 ms |
2644 KB |
Output is correct |
217 |
Correct |
2 ms |
2644 KB |
Output is correct |
218 |
Correct |
2 ms |
2644 KB |
Output is correct |
219 |
Correct |
2 ms |
2644 KB |
Output is correct |
220 |
Correct |
2 ms |
2644 KB |
Output is correct |
221 |
Correct |
2 ms |
2660 KB |
Output is correct |
222 |
Correct |
1 ms |
2664 KB |
Output is correct |
223 |
Correct |
1 ms |
2644 KB |
Output is correct |
224 |
Correct |
2 ms |
2664 KB |
Output is correct |
225 |
Correct |
1 ms |
2668 KB |
Output is correct |
226 |
Correct |
2 ms |
2664 KB |
Output is correct |
227 |
Correct |
2 ms |
2692 KB |
Output is correct |
228 |
Correct |
2 ms |
2688 KB |
Output is correct |
229 |
Correct |
71 ms |
16664 KB |
Output is correct |
230 |
Correct |
82 ms |
15340 KB |
Output is correct |
231 |
Correct |
86 ms |
19060 KB |
Output is correct |
232 |
Correct |
266 ms |
20968 KB |
Output is correct |
233 |
Correct |
166 ms |
19604 KB |
Output is correct |
234 |
Correct |
191 ms |
19924 KB |
Output is correct |
235 |
Correct |
215 ms |
20452 KB |
Output is correct |
236 |
Correct |
88 ms |
18240 KB |
Output is correct |
237 |
Correct |
186 ms |
19512 KB |
Output is correct |
238 |
Correct |
151 ms |
20084 KB |
Output is correct |
239 |
Correct |
103 ms |
25380 KB |
Output is correct |
240 |
Correct |
190 ms |
20900 KB |
Output is correct |
241 |
Correct |
176 ms |
20480 KB |
Output is correct |
242 |
Correct |
37 ms |
18632 KB |
Output is correct |
243 |
Correct |
72 ms |
29288 KB |
Output is correct |
244 |
Correct |
2 ms |
2900 KB |
Output is correct |
245 |
Correct |
3 ms |
2928 KB |
Output is correct |
246 |
Correct |
4 ms |
2964 KB |
Output is correct |
247 |
Correct |
5 ms |
2968 KB |
Output is correct |
248 |
Correct |
4 ms |
3028 KB |
Output is correct |
249 |
Correct |
2 ms |
2644 KB |
Output is correct |
250 |
Correct |
2 ms |
2644 KB |
Output is correct |
251 |
Correct |
2 ms |
2644 KB |
Output is correct |
252 |
Correct |
2 ms |
2644 KB |
Output is correct |
253 |
Correct |
2 ms |
2664 KB |
Output is correct |
254 |
Correct |
108 ms |
13092 KB |
Output is correct |
255 |
Correct |
211 ms |
20128 KB |
Output is correct |
256 |
Correct |
208 ms |
19152 KB |
Output is correct |
257 |
Correct |
220 ms |
20856 KB |
Output is correct |
258 |
Correct |
259 ms |
21208 KB |
Output is correct |
259 |
Correct |
162 ms |
21300 KB |
Output is correct |
260 |
Correct |
101 ms |
18524 KB |
Output is correct |
261 |
Correct |
82 ms |
18148 KB |
Output is correct |
262 |
Correct |
181 ms |
20932 KB |
Output is correct |
263 |
Correct |
93 ms |
19036 KB |
Output is correct |
264 |
Correct |
151 ms |
20992 KB |
Output is correct |
265 |
Correct |
158 ms |
20468 KB |
Output is correct |
266 |
Correct |
131 ms |
20264 KB |
Output is correct |
267 |
Correct |
141 ms |
19208 KB |
Output is correct |
268 |
Correct |
91 ms |
23460 KB |
Output is correct |
269 |
Correct |
123 ms |
19272 KB |
Output is correct |
270 |
Correct |
201 ms |
20976 KB |
Output is correct |
271 |
Correct |
172 ms |
20576 KB |
Output is correct |
272 |
Correct |
2 ms |
2620 KB |
Output is correct |
273 |
Correct |
56 ms |
26644 KB |
Output is correct |
274 |
Correct |
62 ms |
29216 KB |
Output is correct |
275 |
Correct |
3 ms |
2900 KB |
Output is correct |
276 |
Correct |
3 ms |
2980 KB |
Output is correct |
277 |
Correct |
3 ms |
2928 KB |
Output is correct |
278 |
Correct |
4 ms |
3028 KB |
Output is correct |
279 |
Correct |
4 ms |
3028 KB |
Output is correct |
280 |
Correct |
141 ms |
18520 KB |
Output is correct |