#include "joitour.h"
#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &pa) { is >> pa.first >> pa.second; return is; }
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (auto &v : vec) is >> v; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa) { os << "(" << pa.first << "," << pa.second << ")"; return os; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template <typename T> ostream &operator<<(ostream &os, const deque<T> &vec) { os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) { os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template <typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp) { os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template <typename T> void resize_array(vector<T> &vec, int len) { vec.resize(len); }
template <typename T, typename... Args> void resize_array(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) resize_array(v, args...); }
template <typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template <typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }
#define rep(i, a, n) for (int i = a; i < (n); i++)
#define per(i, a, n) for (int i = (n)-1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
#if DEBUG
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
#else
#define dbg(x)
#endif
template <typename T>
class StaticTopTree {
public:
enum Type { Vertex, Compress, Rake, AddEdge, AddVertex };
StaticTopTree(vector<vector<int>> &g, int root = 0) : g_(g), root_(root) {
int n = g_.size();
parent_.resize(4 * n, -1);
left_.resize(4 * n, -1);
right_.resize(4 * n, -1);
vertex_type_.resize(4 * n, Type::Vertex);
paths_.resize(4 * n);
points_.resize(4 * n);
cur_idx_ = n;
build();
}
private:
// do HLD(Heavy Light Decomposition), move heavy edge to g_[c][0];
int dfs(int c) {
int s = 1, best = 0;
for (int &d : g_[c]) {
int t = dfs(d);
s += t;
if (best < t) best = t, swap(d, g_[c][0]);
}
return s;
}
int add(int k, int l, int r, Type t) {
if (k == -1) k = cur_idx_++;
parent_[k] = -1, left_[k] = l, right_[k] = r, vertex_type_[k] = t;
if (l != -1) parent_[l] = k;
if (r != -1) parent_[r] = k;
return k;
}
pair<int, int> merge(const vector<pair<int, int>> &a, Type t) {
if (a.size() == 1) return a[0];
int u = 0;
for (auto &[_, s] : a) u += s;
vector<pair<int, int>> b, c;
// make sure b/c at least has 1 item
for (auto& [i, s] : a) (u > s ? b : c).emplace_back(i, s), u -= s * 2;
// if use (u > 0 ? b : c), c may be 0 size, will be RE
// for (auto &[i, s] : a) (u > 0 ? b : c).emplace_back(i, s), u -= s * 2;
auto [i, si] = merge(b, t);
auto [j, sj] = merge(c, t);
return {add(-1, i, j, t), si + sj};
}
pair<int, int> compress(int i) {
vector<pair<int, int>> chs{add_vertex(i)};
while (!g_[i].empty()) chs.push_back(add_vertex(i = g_[i][0]));
return merge(chs, Type::Compress);
}
pair<int, int> rake(int i) {
vector<pair<int, int>> chs;
for (int j = 1; j < (int)g_[i].size(); j++)
chs.push_back(add_edge(g_[i][j]));
return chs.empty() ? make_pair(-1, 0) : merge(chs, Type::Rake);
}
pair<int, int> add_edge(int i) {
auto [j, sj] = compress(i);
return {add(-1, j, -1, Type::AddEdge), sj};
}
pair<int, int> add_vertex(int i) {
auto [j, sj] = rake(i);
return {add(i, j, -1, j == -1 ? Type::Vertex : Type::AddVertex), sj + 1};
}
void build() {
dfs(root_);
auto [i, n] = compress(root_);
stt_root_ = i;
}
// private:
public:
// adjacent list of initial tree, chridren are stored in g_[parent],
// parent can not be stored in g_[child] in this implement!!!
// g_ must be a rooted tree
vector<vector<int>> &g_;
int root_; // an index of the root in g
int stt_root_; // an index of the root in static top tree
vector<int> parent_, left_, right_; // parent, left child, right child
vector<Type> vertex_type_; // type of vertices
int cur_idx_; // a variable for the index increment
vector<int> values;
private:
// u: upper boundary vertex, v: lower boundary vertex
struct TP {
// c01u -> u can be 1, cu1v -> u or v can be 1
// c0_u_2 -> '_' means u can not be 0/2
ll c012,c01u,c2,c0,cu12,c01v,cv12,cu1v,c0_u_2,cvu_2,c0_uv;
friend ostream &operator<<(ostream &os, const TP &p) {
return os << "c012:" << p.c012 << "\n"
<< "c01u:" << p.c01u << "\n"
<< "c2:" << p.c2 << "\n"
<< "c0:" << p.c0 << "\n"
<< "cu12:" << p.cu12 << "\n"
<< "c01v:" << p.c01v << "\n"
<< "cv12:" << p.cv12 << "\n"
<< "cu1v:" << p.cu1v << "\n"
<< "c0_u_2:" << p.c0_u_2 << "\n"
<< "cvu_2:" << p.cvu_2 << "\n"
<< "c0_uv:" << p.c0_uv << "\n";
}
};
using Point = TP;
using Path = TP;
vector<Point> points_;
vector<Path> paths_;
Path vertex(int i) {
TP tp;
tp.c012 = 0;
tp.c01u = 0;
tp.c2 = (values[i] == 2);
tp.c0 = (values[i] == 0);
tp.cu12 = 0;
tp.c01v = 0;
tp.cv12 = 0;
tp.cu1v = (values[i] == 1);
tp.c0_u_2 = 0;
tp.cvu_2 = 0;
tp.c0_uv = 0;
return tp;
}
Path compress(Path p, Path c) {
TP tp;
tp.c012 = p.c012 + c.c012 + p.c01v * c.c2 + p.cv12 * c.c0 + p.c0 * c.cu12 + p.c2 * c.c01u;
tp.c01u = p.c01u + c.c01u + p.cu1v * c.c0;
tp.c2 = p.c2 + c.c2;
tp.c0 = p.c0 + c.c0;
tp.cu12 = p.cu12 + c.cu12 + p.cu1v * c.c2;
tp.c01v = p.c01v + c.c01v + p.c0 * c.cu1v;
tp.cv12 = p.cv12 + c.cv12 + p.c2 * c.cu1v;
tp.cu1v = p.cu1v + c.cu1v;
tp.c0_u_2 = p.c0_u_2 + c.c0 * p.cvu_2 + c.c2 * p.c0_uv;
tp.cvu_2 = p.cvu_2;
tp.c0_uv = p.c0_uv;
return tp;
}
Path add_vertex(Point p, int i) {
TP tp;
// tp.fv = values[i];
tp.c012 = p.c012 + p.cu12 * (values[i] == 0) + p.c01u * (values[i] == 2) + p.c0_u_2 * (values[i] == 1);
tp.c01u = p.c01u + p.c0 * (values[i] == 1);
tp.c2 = p.c2 + (values[i] == 2);
tp.c0 = p.c0 + (values[i] == 0);
tp.cu12 = p.cu12 + (values[i] == 1) * p.c2;
tp.c01v = tp.c01u;
tp.cv12 = tp.cu12;
tp.cu1v = (values[i] == 1);
tp.c0_u_2 = p.c0_u_2;
tp.cvu_2 = p.c2;
tp.c0_uv = p.c0;
return tp;
}
Point add_edge(Path p) {
TP tp = p;
tp.cu1v = 0;
tp.c0_u_2 = 0;
tp.cvu_2 = 0;
tp.c0_uv = 0;
return tp;
}
Point rake(Point p, Point c) {
TP tp;
// tp.fv = values[i];
tp.c012 = p.c012 + c.c012 + p.c01u * c.c2 + p.cu12 * c.c0 + p.c2 * c.c01u + p.c0 * c.cu12;
tp.c01u = p.c01u + c.c01u;
tp.c2 = p.c2 + c.c2;
tp.c0 = p.c0 + c.c0;
tp.cu12 = p.cu12 + c.cu12;
tp.c01v = 0;
tp.cv12 = 0;
tp.cu1v = 0;
tp.c0_u_2 = p.c0_u_2 + c.c0_u_2 + p.c0 * c.c2 + p.c2 * c.c0;
// tp.cvu_2 = 0;
// tp.c0_uv = 0;
return tp;
}
void update_node(int k) {
if (vertex_type_[k] == Vertex) paths_[k] = vertex(k);
else if (vertex_type_[k] == Compress) paths_[k] = compress(paths_[left_[k]], paths_[right_[k]]);
else if (vertex_type_[k] == AddVertex) paths_[k] = add_vertex(points_[left_[k]], k);
else if (vertex_type_[k] == AddEdge) points_[k] = add_edge(paths_[left_[k]]);
else if (vertex_type_[k] == Rake) points_[k] = rake(points_[left_[k]], points_[right_[k]]);
}
void init(int k) {
if (left_[k] != -1) init(left_[k]);
if (right_[k] != -1) init(right_[k]);
update_node(k);
dbg(mp(k, vertex_type_[k]));
dbg(points_[k]);
dbg(paths_[k]);
}
public:
void update_tree(int k, T v) {
values[k] = v;
while (k != -1) {
update_node(k);
k = parent_[k];
}
}
void init() {
init(stt_root_);
}
T get_answer() {
return paths_[stt_root_].c012;
}
};
unique_ptr<StaticTopTree<ll>> p_stt = nullptr;
void init(int N, std::vector<int> F, std::vector<int> U, std::vector<int> V, int Q) {
vector<vi> edges(N);
rep(i,0,N-1) {
edges[U[i]].emplace_back(V[i]);
edges[V[i]].emplace_back(U[i]);
}
vector<vi> g(N);
function<void(int,int)> dfs=[&] (int u, int p) {
for(int v : edges[u]) {
if (v != p) {
g[u].emplace_back(v);
dfs(v, u);
}
}
};
dfs(0, -1);
dbg(g);
p_stt = make_unique<StaticTopTree<ll>>(g);
p_stt->values = F;
dbg(p_stt->values);
p_stt->init();
}
void change(int X, int Y) {
p_stt->update_tree(X, Y);
}
long long num_tours() {
return p_stt->get_answer();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
856 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
856 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
8 ms |
4440 KB |
Output is correct |
26 |
Correct |
8 ms |
4216 KB |
Output is correct |
27 |
Correct |
9 ms |
4176 KB |
Output is correct |
28 |
Correct |
7 ms |
4696 KB |
Output is correct |
29 |
Correct |
7 ms |
4184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
319 ms |
194252 KB |
Output is correct |
3 |
Correct |
236 ms |
193268 KB |
Output is correct |
4 |
Correct |
272 ms |
188968 KB |
Output is correct |
5 |
Correct |
237 ms |
195456 KB |
Output is correct |
6 |
Correct |
116 ms |
175156 KB |
Output is correct |
7 |
Correct |
123 ms |
175480 KB |
Output is correct |
8 |
Correct |
179 ms |
174292 KB |
Output is correct |
9 |
Correct |
203 ms |
175320 KB |
Output is correct |
10 |
Correct |
201 ms |
175380 KB |
Output is correct |
11 |
Correct |
196 ms |
175836 KB |
Output is correct |
12 |
Correct |
214 ms |
182756 KB |
Output is correct |
13 |
Correct |
202 ms |
182540 KB |
Output is correct |
14 |
Correct |
198 ms |
182192 KB |
Output is correct |
15 |
Correct |
221 ms |
181028 KB |
Output is correct |
16 |
Correct |
246 ms |
199268 KB |
Output is correct |
17 |
Correct |
1 ms |
540 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
225 ms |
176044 KB |
Output is correct |
22 |
Correct |
206 ms |
176304 KB |
Output is correct |
23 |
Correct |
225 ms |
176064 KB |
Output is correct |
24 |
Correct |
215 ms |
175836 KB |
Output is correct |
25 |
Correct |
156 ms |
177480 KB |
Output is correct |
26 |
Correct |
162 ms |
177632 KB |
Output is correct |
27 |
Correct |
177 ms |
177488 KB |
Output is correct |
28 |
Correct |
168 ms |
177396 KB |
Output is correct |
29 |
Correct |
145 ms |
204060 KB |
Output is correct |
30 |
Correct |
150 ms |
204116 KB |
Output is correct |
31 |
Correct |
155 ms |
204200 KB |
Output is correct |
32 |
Correct |
150 ms |
204116 KB |
Output is correct |
33 |
Correct |
131 ms |
174820 KB |
Output is correct |
34 |
Correct |
130 ms |
174968 KB |
Output is correct |
35 |
Correct |
114 ms |
174808 KB |
Output is correct |
36 |
Correct |
122 ms |
174804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
856 KB |
Output is correct |
8 |
Correct |
8 ms |
4696 KB |
Output is correct |
9 |
Correct |
147 ms |
204244 KB |
Output is correct |
10 |
Correct |
144 ms |
204192 KB |
Output is correct |
11 |
Correct |
157 ms |
204112 KB |
Output is correct |
12 |
Correct |
156 ms |
204112 KB |
Output is correct |
13 |
Correct |
219 ms |
102352 KB |
Output is correct |
14 |
Correct |
208 ms |
102320 KB |
Output is correct |
15 |
Correct |
206 ms |
102320 KB |
Output is correct |
16 |
Correct |
221 ms |
102288 KB |
Output is correct |
17 |
Correct |
252 ms |
102324 KB |
Output is correct |
18 |
Correct |
230 ms |
102324 KB |
Output is correct |
19 |
Correct |
450 ms |
204128 KB |
Output is correct |
20 |
Correct |
401 ms |
204124 KB |
Output is correct |
21 |
Correct |
506 ms |
204120 KB |
Output is correct |
22 |
Correct |
456 ms |
204116 KB |
Output is correct |
23 |
Correct |
444 ms |
204336 KB |
Output is correct |
24 |
Correct |
447 ms |
204240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
8 ms |
3936 KB |
Output is correct |
8 |
Correct |
115 ms |
174996 KB |
Output is correct |
9 |
Correct |
118 ms |
174908 KB |
Output is correct |
10 |
Correct |
114 ms |
174992 KB |
Output is correct |
11 |
Correct |
114 ms |
174828 KB |
Output is correct |
12 |
Correct |
179 ms |
87612 KB |
Output is correct |
13 |
Correct |
247 ms |
87736 KB |
Output is correct |
14 |
Correct |
221 ms |
87484 KB |
Output is correct |
15 |
Correct |
225 ms |
87620 KB |
Output is correct |
16 |
Correct |
235 ms |
87528 KB |
Output is correct |
17 |
Correct |
251 ms |
87632 KB |
Output is correct |
18 |
Correct |
419 ms |
174820 KB |
Output is correct |
19 |
Correct |
477 ms |
174996 KB |
Output is correct |
20 |
Correct |
507 ms |
174816 KB |
Output is correct |
21 |
Correct |
485 ms |
175020 KB |
Output is correct |
22 |
Correct |
487 ms |
174816 KB |
Output is correct |
23 |
Correct |
478 ms |
175028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
856 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
8 ms |
4440 KB |
Output is correct |
26 |
Correct |
8 ms |
4216 KB |
Output is correct |
27 |
Correct |
9 ms |
4176 KB |
Output is correct |
28 |
Correct |
7 ms |
4696 KB |
Output is correct |
29 |
Correct |
7 ms |
4184 KB |
Output is correct |
30 |
Correct |
222 ms |
94464 KB |
Output is correct |
31 |
Correct |
246 ms |
96256 KB |
Output is correct |
32 |
Correct |
294 ms |
96372 KB |
Output is correct |
33 |
Correct |
261 ms |
97652 KB |
Output is correct |
34 |
Correct |
275 ms |
97964 KB |
Output is correct |
35 |
Correct |
275 ms |
95952 KB |
Output is correct |
36 |
Correct |
239 ms |
87740 KB |
Output is correct |
37 |
Correct |
246 ms |
87680 KB |
Output is correct |
38 |
Correct |
268 ms |
87324 KB |
Output is correct |
39 |
Correct |
275 ms |
87724 KB |
Output is correct |
40 |
Correct |
259 ms |
87692 KB |
Output is correct |
41 |
Correct |
271 ms |
88304 KB |
Output is correct |
42 |
Correct |
238 ms |
91336 KB |
Output is correct |
43 |
Correct |
258 ms |
90088 KB |
Output is correct |
44 |
Correct |
246 ms |
90596 KB |
Output is correct |
45 |
Correct |
251 ms |
91500 KB |
Output is correct |
46 |
Correct |
265 ms |
90312 KB |
Output is correct |
47 |
Correct |
265 ms |
91644 KB |
Output is correct |
48 |
Correct |
250 ms |
97168 KB |
Output is correct |
49 |
Correct |
278 ms |
99584 KB |
Output is correct |
50 |
Correct |
255 ms |
96520 KB |
Output is correct |
51 |
Correct |
236 ms |
88100 KB |
Output is correct |
52 |
Correct |
243 ms |
88240 KB |
Output is correct |
53 |
Correct |
276 ms |
88128 KB |
Output is correct |
54 |
Correct |
255 ms |
88124 KB |
Output is correct |
55 |
Correct |
301 ms |
88276 KB |
Output is correct |
56 |
Correct |
265 ms |
88108 KB |
Output is correct |
57 |
Correct |
203 ms |
89024 KB |
Output is correct |
58 |
Correct |
211 ms |
88980 KB |
Output is correct |
59 |
Correct |
226 ms |
89036 KB |
Output is correct |
60 |
Correct |
236 ms |
89040 KB |
Output is correct |
61 |
Correct |
216 ms |
89032 KB |
Output is correct |
62 |
Correct |
213 ms |
102340 KB |
Output is correct |
63 |
Correct |
190 ms |
102340 KB |
Output is correct |
64 |
Correct |
228 ms |
102324 KB |
Output is correct |
65 |
Correct |
212 ms |
102324 KB |
Output is correct |
66 |
Correct |
240 ms |
102252 KB |
Output is correct |
67 |
Correct |
232 ms |
102096 KB |
Output is correct |
68 |
Correct |
182 ms |
87612 KB |
Output is correct |
69 |
Correct |
207 ms |
87616 KB |
Output is correct |
70 |
Correct |
218 ms |
87636 KB |
Output is correct |
71 |
Correct |
216 ms |
87612 KB |
Output is correct |
72 |
Correct |
231 ms |
87724 KB |
Output is correct |
73 |
Correct |
269 ms |
87632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
600 KB |
Output is correct |
5 |
Correct |
1 ms |
504 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
344 KB |
Output is correct |
14 |
Correct |
0 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
856 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
344 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
8 ms |
4440 KB |
Output is correct |
26 |
Correct |
8 ms |
4216 KB |
Output is correct |
27 |
Correct |
9 ms |
4176 KB |
Output is correct |
28 |
Correct |
7 ms |
4696 KB |
Output is correct |
29 |
Correct |
7 ms |
4184 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
319 ms |
194252 KB |
Output is correct |
32 |
Correct |
236 ms |
193268 KB |
Output is correct |
33 |
Correct |
272 ms |
188968 KB |
Output is correct |
34 |
Correct |
237 ms |
195456 KB |
Output is correct |
35 |
Correct |
116 ms |
175156 KB |
Output is correct |
36 |
Correct |
123 ms |
175480 KB |
Output is correct |
37 |
Correct |
179 ms |
174292 KB |
Output is correct |
38 |
Correct |
203 ms |
175320 KB |
Output is correct |
39 |
Correct |
201 ms |
175380 KB |
Output is correct |
40 |
Correct |
196 ms |
175836 KB |
Output is correct |
41 |
Correct |
214 ms |
182756 KB |
Output is correct |
42 |
Correct |
202 ms |
182540 KB |
Output is correct |
43 |
Correct |
198 ms |
182192 KB |
Output is correct |
44 |
Correct |
221 ms |
181028 KB |
Output is correct |
45 |
Correct |
246 ms |
199268 KB |
Output is correct |
46 |
Correct |
1 ms |
540 KB |
Output is correct |
47 |
Correct |
0 ms |
344 KB |
Output is correct |
48 |
Correct |
0 ms |
344 KB |
Output is correct |
49 |
Correct |
0 ms |
344 KB |
Output is correct |
50 |
Correct |
225 ms |
176044 KB |
Output is correct |
51 |
Correct |
206 ms |
176304 KB |
Output is correct |
52 |
Correct |
225 ms |
176064 KB |
Output is correct |
53 |
Correct |
215 ms |
175836 KB |
Output is correct |
54 |
Correct |
156 ms |
177480 KB |
Output is correct |
55 |
Correct |
162 ms |
177632 KB |
Output is correct |
56 |
Correct |
177 ms |
177488 KB |
Output is correct |
57 |
Correct |
168 ms |
177396 KB |
Output is correct |
58 |
Correct |
145 ms |
204060 KB |
Output is correct |
59 |
Correct |
150 ms |
204116 KB |
Output is correct |
60 |
Correct |
155 ms |
204200 KB |
Output is correct |
61 |
Correct |
150 ms |
204116 KB |
Output is correct |
62 |
Correct |
131 ms |
174820 KB |
Output is correct |
63 |
Correct |
130 ms |
174968 KB |
Output is correct |
64 |
Correct |
114 ms |
174808 KB |
Output is correct |
65 |
Correct |
122 ms |
174804 KB |
Output is correct |
66 |
Correct |
0 ms |
344 KB |
Output is correct |
67 |
Correct |
0 ms |
344 KB |
Output is correct |
68 |
Correct |
1 ms |
344 KB |
Output is correct |
69 |
Correct |
1 ms |
344 KB |
Output is correct |
70 |
Correct |
1 ms |
344 KB |
Output is correct |
71 |
Correct |
1 ms |
344 KB |
Output is correct |
72 |
Correct |
1 ms |
856 KB |
Output is correct |
73 |
Correct |
8 ms |
4696 KB |
Output is correct |
74 |
Correct |
147 ms |
204244 KB |
Output is correct |
75 |
Correct |
144 ms |
204192 KB |
Output is correct |
76 |
Correct |
157 ms |
204112 KB |
Output is correct |
77 |
Correct |
156 ms |
204112 KB |
Output is correct |
78 |
Correct |
219 ms |
102352 KB |
Output is correct |
79 |
Correct |
208 ms |
102320 KB |
Output is correct |
80 |
Correct |
206 ms |
102320 KB |
Output is correct |
81 |
Correct |
221 ms |
102288 KB |
Output is correct |
82 |
Correct |
252 ms |
102324 KB |
Output is correct |
83 |
Correct |
230 ms |
102324 KB |
Output is correct |
84 |
Correct |
450 ms |
204128 KB |
Output is correct |
85 |
Correct |
401 ms |
204124 KB |
Output is correct |
86 |
Correct |
506 ms |
204120 KB |
Output is correct |
87 |
Correct |
456 ms |
204116 KB |
Output is correct |
88 |
Correct |
444 ms |
204336 KB |
Output is correct |
89 |
Correct |
447 ms |
204240 KB |
Output is correct |
90 |
Correct |
0 ms |
344 KB |
Output is correct |
91 |
Correct |
1 ms |
344 KB |
Output is correct |
92 |
Correct |
1 ms |
344 KB |
Output is correct |
93 |
Correct |
1 ms |
344 KB |
Output is correct |
94 |
Correct |
1 ms |
344 KB |
Output is correct |
95 |
Correct |
2 ms |
600 KB |
Output is correct |
96 |
Correct |
8 ms |
3936 KB |
Output is correct |
97 |
Correct |
115 ms |
174996 KB |
Output is correct |
98 |
Correct |
118 ms |
174908 KB |
Output is correct |
99 |
Correct |
114 ms |
174992 KB |
Output is correct |
100 |
Correct |
114 ms |
174828 KB |
Output is correct |
101 |
Correct |
179 ms |
87612 KB |
Output is correct |
102 |
Correct |
247 ms |
87736 KB |
Output is correct |
103 |
Correct |
221 ms |
87484 KB |
Output is correct |
104 |
Correct |
225 ms |
87620 KB |
Output is correct |
105 |
Correct |
235 ms |
87528 KB |
Output is correct |
106 |
Correct |
251 ms |
87632 KB |
Output is correct |
107 |
Correct |
419 ms |
174820 KB |
Output is correct |
108 |
Correct |
477 ms |
174996 KB |
Output is correct |
109 |
Correct |
507 ms |
174816 KB |
Output is correct |
110 |
Correct |
485 ms |
175020 KB |
Output is correct |
111 |
Correct |
487 ms |
174816 KB |
Output is correct |
112 |
Correct |
478 ms |
175028 KB |
Output is correct |
113 |
Correct |
222 ms |
94464 KB |
Output is correct |
114 |
Correct |
246 ms |
96256 KB |
Output is correct |
115 |
Correct |
294 ms |
96372 KB |
Output is correct |
116 |
Correct |
261 ms |
97652 KB |
Output is correct |
117 |
Correct |
275 ms |
97964 KB |
Output is correct |
118 |
Correct |
275 ms |
95952 KB |
Output is correct |
119 |
Correct |
239 ms |
87740 KB |
Output is correct |
120 |
Correct |
246 ms |
87680 KB |
Output is correct |
121 |
Correct |
268 ms |
87324 KB |
Output is correct |
122 |
Correct |
275 ms |
87724 KB |
Output is correct |
123 |
Correct |
259 ms |
87692 KB |
Output is correct |
124 |
Correct |
271 ms |
88304 KB |
Output is correct |
125 |
Correct |
238 ms |
91336 KB |
Output is correct |
126 |
Correct |
258 ms |
90088 KB |
Output is correct |
127 |
Correct |
246 ms |
90596 KB |
Output is correct |
128 |
Correct |
251 ms |
91500 KB |
Output is correct |
129 |
Correct |
265 ms |
90312 KB |
Output is correct |
130 |
Correct |
265 ms |
91644 KB |
Output is correct |
131 |
Correct |
250 ms |
97168 KB |
Output is correct |
132 |
Correct |
278 ms |
99584 KB |
Output is correct |
133 |
Correct |
255 ms |
96520 KB |
Output is correct |
134 |
Correct |
236 ms |
88100 KB |
Output is correct |
135 |
Correct |
243 ms |
88240 KB |
Output is correct |
136 |
Correct |
276 ms |
88128 KB |
Output is correct |
137 |
Correct |
255 ms |
88124 KB |
Output is correct |
138 |
Correct |
301 ms |
88276 KB |
Output is correct |
139 |
Correct |
265 ms |
88108 KB |
Output is correct |
140 |
Correct |
203 ms |
89024 KB |
Output is correct |
141 |
Correct |
211 ms |
88980 KB |
Output is correct |
142 |
Correct |
226 ms |
89036 KB |
Output is correct |
143 |
Correct |
236 ms |
89040 KB |
Output is correct |
144 |
Correct |
216 ms |
89032 KB |
Output is correct |
145 |
Correct |
213 ms |
102340 KB |
Output is correct |
146 |
Correct |
190 ms |
102340 KB |
Output is correct |
147 |
Correct |
228 ms |
102324 KB |
Output is correct |
148 |
Correct |
212 ms |
102324 KB |
Output is correct |
149 |
Correct |
240 ms |
102252 KB |
Output is correct |
150 |
Correct |
232 ms |
102096 KB |
Output is correct |
151 |
Correct |
182 ms |
87612 KB |
Output is correct |
152 |
Correct |
207 ms |
87616 KB |
Output is correct |
153 |
Correct |
218 ms |
87636 KB |
Output is correct |
154 |
Correct |
216 ms |
87612 KB |
Output is correct |
155 |
Correct |
231 ms |
87724 KB |
Output is correct |
156 |
Correct |
269 ms |
87632 KB |
Output is correct |
157 |
Correct |
550 ms |
191964 KB |
Output is correct |
158 |
Correct |
540 ms |
193612 KB |
Output is correct |
159 |
Correct |
576 ms |
191480 KB |
Output is correct |
160 |
Correct |
554 ms |
189100 KB |
Output is correct |
161 |
Correct |
607 ms |
195024 KB |
Output is correct |
162 |
Correct |
533 ms |
194576 KB |
Output is correct |
163 |
Correct |
459 ms |
175328 KB |
Output is correct |
164 |
Correct |
492 ms |
175328 KB |
Output is correct |
165 |
Correct |
565 ms |
174488 KB |
Output is correct |
166 |
Correct |
554 ms |
175084 KB |
Output is correct |
167 |
Correct |
595 ms |
175068 KB |
Output is correct |
168 |
Correct |
567 ms |
176364 KB |
Output is correct |
169 |
Correct |
470 ms |
182172 KB |
Output is correct |
170 |
Correct |
530 ms |
180608 KB |
Output is correct |
171 |
Correct |
524 ms |
180800 KB |
Output is correct |
172 |
Correct |
523 ms |
179684 KB |
Output is correct |
173 |
Correct |
528 ms |
181316 KB |
Output is correct |
174 |
Correct |
542 ms |
182388 KB |
Output is correct |
175 |
Correct |
581 ms |
193460 KB |
Output is correct |
176 |
Correct |
531 ms |
197920 KB |
Output is correct |
177 |
Correct |
568 ms |
203168 KB |
Output is correct |
178 |
Correct |
513 ms |
175820 KB |
Output is correct |
179 |
Correct |
563 ms |
176096 KB |
Output is correct |
180 |
Correct |
580 ms |
175868 KB |
Output is correct |
181 |
Correct |
598 ms |
175832 KB |
Output is correct |
182 |
Correct |
604 ms |
176000 KB |
Output is correct |
183 |
Correct |
591 ms |
176044 KB |
Output is correct |
184 |
Correct |
438 ms |
177480 KB |
Output is correct |
185 |
Correct |
502 ms |
177608 KB |
Output is correct |
186 |
Correct |
501 ms |
177576 KB |
Output is correct |
187 |
Correct |
514 ms |
177592 KB |
Output is correct |
188 |
Correct |
561 ms |
177604 KB |
Output is correct |