#include <bits/stdc++.h>
using namespace std;
using db = long double;
using ll = long long;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
#define vt vector
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end()
#define size(x) ((int) (x).size())
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define F0R(i, b) FOR (i, 0, b)
#define endl '\n'
const ll INF = 1e18;
const int inf = 1e9;
template<typename... Args> // tuples
ostream& operator<<(ostream& os, tuple<Args...> t) {
apply([&](Args... args) { string dlm = "{"; ((os << dlm << args, dlm = ", "), ...); }, t);
return os << "}";
}
template<typename T, typename V> // pairs
ostream& operator<<(ostream& os, pair<T, V> p) { return os << "{" << p.f << ", " << p.s << "}"; }
template<class T, class = decltype(begin(declval<T>()))> // iterables
typename enable_if<!is_same<T, string>::value, ostream&>::type operator<<(ostream& os, const T& v) {
string dlm = "{";
for (auto i : v) os << dlm << i, dlm = ", ";
return os << "}";
}
template <typename T, typename... V>
void printer(string pfx, const char *names, T&& head, V&& ...tail) {
int i = 0;
while (names[i] && names[i] != ',') i++;
constexpr bool is_str = is_same_v<decay_t<T>, const char*>;
if (is_str) cerr << " " << head;
else cerr << pfx, cerr.write(names, i) << " = " << head;
if constexpr (sizeof...(tail)) printer(is_str ? "" : ",", names + i + 1, tail...);
else cerr << endl;
}
#ifdef LOCAL
#define dbg(...) printer(to_string(__LINE__) + ": ", #__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(x...)
#define cerr if (0) std::cerr
#endif
/*
consider when its *not* possible to find a path between three nodes a, b and c
obv, they need to be in the same connected component
clearly, you can go from a to b, and you can also go from b to c
we just need to account for the condition that you cant use the same node twice
consider the block cut tree
a triple is good as long as a, b, and c belong on the same path, in that order
do subtree dp, counting the # of paths with it as their lca
be very careful, since neighbours in the block cut tree share a node which we must not overcount
when counting for some lca, we exclude the shared node with children
cases:
- we can take a pair from some subtree (excluding shared) and one from another
- we can take a node each from two subtrees (excluding shared) and one in the root
- we can take a pair from a subtree (excluding shared) and one from the root (excluding shared)
additionally, if the root has sufficient nodes
- we can take two nodes from the root and some node (excluding shared) in a subtree
- we can take three nodes from the root
we need to track in our dp:
- how many unique child nodes there are in the subtree (careful overcounting articulation points)
- this is size of yourself + dp value of children - # of children
- how many ordered pairs there are in the subtree that lead to the root EXCLUDING the shared node with the parent
- sum of pairs of children, and (sum of child sizes excluding shared) * (size of root - 1), and (size - 1) * (size - 2)
sum over all roots
*/
struct BCC {
int n, t;
vt<vt<int>> adj;
vt<int> tin, low, stk;
vt<bool> is_art;
vt<vt<int>> comps;
void init(int _n) {
n = _n;
t = 0;
adj.resize(n);
tin = low = vt<int>(n);
is_art.resize(n);
}
void ae(int u, int v) {
adj[u].pb(v);
adj[v].pb(u);
}
void dfs(int u) {
tin[u] = low[u] = ++t;
stk.pb(u);
for (int v : adj[u]) {
if (tin[v]) low[u] = min(low[u], tin[v]);
else {
dfs(v);
low[u] = min(low[u], low[v]);
if (low[v] == tin[u]) {
is_art[u] = (u != stk[0]) || tin[v] > tin[u] + 1;
comps.pb({u});
do {
comps.back().pb(stk.back());
stk.pop_back();
} while (comps.back().back() != v);
}
}
}
}
void gen() {
F0R (i, n) if (!tin[i]) dfs(i);
for (auto c : comps) dbg(c);
}
};
int n;
BCC bcc;
vt<vt<int>> adj;
vt<int> id;
vt<ll> sz;
vt<vt<int>> rcomp;
vt<ll> sub, pairs;
vt<bool> seen;
ll ans = 0;
void dfs(int u, int p) {
seen[u] = true;
for (int v : adj[u]) if (v != p) dfs(v, u);
// do the first three cases, since they are shared
ll available = 0; // # of nodes in children that arent part of the root
for (int v : adj[u]) {
if (v == p) continue;
available += sub[v] - 1; // exclude the shared node
}
// case 1
for (int v : adj[u]) {
if (v == p) continue;
ans += pairs[v] * (available - (sub[v] - 1)) * 2;
}
// case 2
for (int v : adj[u]) {
if (v == p) continue;
ans += sz[u] * (sub[v] - 1) * (available - (sub[v] - 1));
}
// case 3
for (int v : adj[u]) {
if (v == p) continue;
ans += (sz[u] - 1) * pairs[v] * 2;
}
// case 4
for (int v : adj[u]) {
if (v == p) continue;
ans += (sz[u] - 1) * (sub[v] - 1) * 2 + (sz[u] - 1) * (sz[u] - 2) * (sub[v] - 1) * 2;
}
// case 5
ans += sz[u] * (sz[u] - 1) * (sz[u] - 2);
// calc dp values
sub[u] = available + sz[u];
pairs[u] = available * (sz[u] - 1) + (sz[u] - 1) * (sz[u] - 2);
for (int v : adj[u]) {
if (v == p) continue;
pairs[u] += pairs[v];
}
dbg("\n", rcomp[u]);
dbg(ans, sub[u], pairs[u], sz[u]);
}
/*
do subtree dp, counting the # of paths with it as their lca
be very careful, since neighbours in the block cut tree share a node which we must not overcount
when counting for some lca, we exclude the shared node with children
cases:
- we can take a pair from some subtree (excluding shared) and one from another
- we can take a node each from two subtrees (excluding shared) and one in the root
- we can take a pair from a subtree (excluding shared) and one from the root (excluding shared)
additionally, if the root has sufficient nodes
- we can take two nodes from the root and some node (excluding shared) in a subtree
- case 1: includes the shared node
- case 2: exclues shared node
- we can take three nodes from the root (any)
we need to track in our dp:
- how many unique child nodes there are in the subtree (careful overcounting articulation points)
- this is size of yourself + dp value of children - # of children
- how many ordered pairs there are in the subtree that lead to the root EXCLUDING the shared node with the parent
- sum of pairs of children, and (sum of child sizes excluding shared) * (size of root - 1), and (size - 1) * (size - 2)
sum over all roots
*/
main() {
cin.tie(0)->sync_with_stdio(0);
int _n; cin >> _n;
bcc.init(_n);
int m; cin >> m;
F0R (i, m) {
int u, v; cin >> u >> v; u--, v--;
bcc.ae(u, v);
}
bcc.gen();
// build block cut tree
id.resize(_n);
F0R (i, _n) {
if (bcc.is_art[i]) {
id[i] = n++;
sz.pb(1);
adj.pb({});
rcomp.pb({i});
}
}
for (vt<int>& comp : bcc.comps) {
adj.pb({});
sz.pb(size(comp));
for (int u : comp) {
if (bcc.is_art[u]) {
adj[id[u]].pb(n);
adj[n].pb(id[u]);
}
}
rcomp.pb(comp);
n++;
}
dbg(bcc.is_art);
// start counting
dbg(n);
sub = pairs = vt<ll>(n);
seen.resize(n);
F0R (i, n) {
if (!seen[i]) dfs(i, -1);
}
cout << ans << endl;
}
Compilation message
count_triplets.cpp:225:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
225 | main() {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
460 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
456 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
460 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
456 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
344 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
344 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
604 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
0 ms |
348 KB |
Output is correct |
51 |
Correct |
0 ms |
348 KB |
Output is correct |
52 |
Correct |
0 ms |
348 KB |
Output is correct |
53 |
Correct |
0 ms |
348 KB |
Output is correct |
54 |
Correct |
0 ms |
348 KB |
Output is correct |
55 |
Correct |
0 ms |
348 KB |
Output is correct |
56 |
Correct |
0 ms |
348 KB |
Output is correct |
57 |
Correct |
0 ms |
348 KB |
Output is correct |
58 |
Correct |
0 ms |
348 KB |
Output is correct |
59 |
Correct |
0 ms |
348 KB |
Output is correct |
60 |
Correct |
0 ms |
348 KB |
Output is correct |
61 |
Correct |
0 ms |
348 KB |
Output is correct |
62 |
Correct |
0 ms |
348 KB |
Output is correct |
63 |
Correct |
0 ms |
452 KB |
Output is correct |
64 |
Correct |
0 ms |
348 KB |
Output is correct |
65 |
Correct |
0 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
19144 KB |
Output is correct |
2 |
Correct |
28 ms |
19152 KB |
Output is correct |
3 |
Correct |
64 ms |
30220 KB |
Output is correct |
4 |
Correct |
38 ms |
24276 KB |
Output is correct |
5 |
Correct |
40 ms |
24164 KB |
Output is correct |
6 |
Correct |
50 ms |
30448 KB |
Output is correct |
7 |
Correct |
50 ms |
29748 KB |
Output is correct |
8 |
Correct |
84 ms |
30208 KB |
Output is correct |
9 |
Correct |
51 ms |
28424 KB |
Output is correct |
10 |
Correct |
72 ms |
26372 KB |
Output is correct |
11 |
Correct |
43 ms |
23180 KB |
Output is correct |
12 |
Correct |
39 ms |
22240 KB |
Output is correct |
13 |
Correct |
36 ms |
21816 KB |
Output is correct |
14 |
Correct |
56 ms |
22020 KB |
Output is correct |
15 |
Correct |
49 ms |
19720 KB |
Output is correct |
16 |
Correct |
37 ms |
19208 KB |
Output is correct |
17 |
Correct |
3 ms |
4324 KB |
Output is correct |
18 |
Correct |
2 ms |
4324 KB |
Output is correct |
19 |
Correct |
3 ms |
4352 KB |
Output is correct |
20 |
Correct |
2 ms |
4324 KB |
Output is correct |
21 |
Correct |
3 ms |
4316 KB |
Output is correct |
22 |
Correct |
2 ms |
4316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
860 KB |
Output is correct |
6 |
Correct |
1 ms |
860 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
860 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
0 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
35648 KB |
Output is correct |
2 |
Correct |
64 ms |
33276 KB |
Output is correct |
3 |
Correct |
57 ms |
35580 KB |
Output is correct |
4 |
Correct |
73 ms |
33660 KB |
Output is correct |
5 |
Correct |
88 ms |
34252 KB |
Output is correct |
6 |
Correct |
69 ms |
48116 KB |
Output is correct |
7 |
Correct |
73 ms |
44280 KB |
Output is correct |
8 |
Correct |
63 ms |
43256 KB |
Output is correct |
9 |
Correct |
69 ms |
41460 KB |
Output is correct |
10 |
Correct |
56 ms |
33536 KB |
Output is correct |
11 |
Correct |
54 ms |
33020 KB |
Output is correct |
12 |
Correct |
90 ms |
36852 KB |
Output is correct |
13 |
Correct |
58 ms |
35328 KB |
Output is correct |
14 |
Correct |
55 ms |
32252 KB |
Output is correct |
15 |
Correct |
74 ms |
32000 KB |
Output is correct |
16 |
Correct |
35 ms |
21508 KB |
Output is correct |
17 |
Correct |
34 ms |
27196 KB |
Output is correct |
18 |
Correct |
44 ms |
28412 KB |
Output is correct |
19 |
Correct |
35 ms |
27460 KB |
Output is correct |
20 |
Correct |
35 ms |
27800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
720 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
856 KB |
Output is correct |
16 |
Correct |
0 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
644 KB |
Output is correct |
18 |
Correct |
0 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
604 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
36100 KB |
Output is correct |
2 |
Correct |
71 ms |
34584 KB |
Output is correct |
3 |
Correct |
90 ms |
33620 KB |
Output is correct |
4 |
Correct |
52 ms |
26124 KB |
Output is correct |
5 |
Correct |
38 ms |
19208 KB |
Output is correct |
6 |
Correct |
36 ms |
16248 KB |
Output is correct |
7 |
Correct |
32 ms |
14856 KB |
Output is correct |
8 |
Correct |
32 ms |
12936 KB |
Output is correct |
9 |
Correct |
41 ms |
12060 KB |
Output is correct |
10 |
Correct |
30 ms |
11488 KB |
Output is correct |
11 |
Correct |
26 ms |
10588 KB |
Output is correct |
12 |
Correct |
38 ms |
9708 KB |
Output is correct |
13 |
Correct |
26 ms |
9780 KB |
Output is correct |
14 |
Correct |
30 ms |
12328 KB |
Output is correct |
15 |
Correct |
61 ms |
40528 KB |
Output is correct |
16 |
Correct |
63 ms |
39420 KB |
Output is correct |
17 |
Correct |
56 ms |
37504 KB |
Output is correct |
18 |
Correct |
61 ms |
33032 KB |
Output is correct |
19 |
Correct |
54 ms |
25844 KB |
Output is correct |
20 |
Correct |
49 ms |
25772 KB |
Output is correct |
21 |
Correct |
49 ms |
25776 KB |
Output is correct |
22 |
Correct |
70 ms |
24104 KB |
Output is correct |
23 |
Correct |
38 ms |
21708 KB |
Output is correct |
24 |
Correct |
46 ms |
29768 KB |
Output is correct |
25 |
Correct |
58 ms |
30068 KB |
Output is correct |
26 |
Correct |
55 ms |
26976 KB |
Output is correct |
27 |
Correct |
79 ms |
28420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
460 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
456 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
344 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
344 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
604 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
0 ms |
348 KB |
Output is correct |
51 |
Correct |
0 ms |
348 KB |
Output is correct |
52 |
Correct |
0 ms |
348 KB |
Output is correct |
53 |
Correct |
0 ms |
348 KB |
Output is correct |
54 |
Correct |
0 ms |
348 KB |
Output is correct |
55 |
Correct |
0 ms |
348 KB |
Output is correct |
56 |
Correct |
0 ms |
348 KB |
Output is correct |
57 |
Correct |
0 ms |
348 KB |
Output is correct |
58 |
Correct |
0 ms |
348 KB |
Output is correct |
59 |
Correct |
0 ms |
348 KB |
Output is correct |
60 |
Correct |
0 ms |
348 KB |
Output is correct |
61 |
Correct |
0 ms |
348 KB |
Output is correct |
62 |
Correct |
0 ms |
348 KB |
Output is correct |
63 |
Correct |
0 ms |
452 KB |
Output is correct |
64 |
Correct |
0 ms |
348 KB |
Output is correct |
65 |
Correct |
0 ms |
456 KB |
Output is correct |
66 |
Correct |
1 ms |
348 KB |
Output is correct |
67 |
Correct |
1 ms |
604 KB |
Output is correct |
68 |
Correct |
1 ms |
604 KB |
Output is correct |
69 |
Correct |
1 ms |
468 KB |
Output is correct |
70 |
Correct |
0 ms |
604 KB |
Output is correct |
71 |
Correct |
0 ms |
604 KB |
Output is correct |
72 |
Correct |
0 ms |
604 KB |
Output is correct |
73 |
Correct |
0 ms |
604 KB |
Output is correct |
74 |
Correct |
1 ms |
456 KB |
Output is correct |
75 |
Correct |
1 ms |
604 KB |
Output is correct |
76 |
Correct |
1 ms |
348 KB |
Output is correct |
77 |
Correct |
1 ms |
716 KB |
Output is correct |
78 |
Correct |
1 ms |
644 KB |
Output is correct |
79 |
Correct |
1 ms |
348 KB |
Output is correct |
80 |
Correct |
0 ms |
348 KB |
Output is correct |
81 |
Correct |
0 ms |
460 KB |
Output is correct |
82 |
Correct |
1 ms |
604 KB |
Output is correct |
83 |
Correct |
1 ms |
604 KB |
Output is correct |
84 |
Correct |
1 ms |
604 KB |
Output is correct |
85 |
Correct |
0 ms |
604 KB |
Output is correct |
86 |
Correct |
1 ms |
604 KB |
Output is correct |
87 |
Correct |
1 ms |
604 KB |
Output is correct |
88 |
Correct |
1 ms |
604 KB |
Output is correct |
89 |
Correct |
1 ms |
604 KB |
Output is correct |
90 |
Correct |
1 ms |
604 KB |
Output is correct |
91 |
Correct |
0 ms |
604 KB |
Output is correct |
92 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 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 |
460 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
344 KB |
Output is correct |
26 |
Correct |
0 ms |
348 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
0 ms |
456 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
344 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
344 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
604 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
0 ms |
348 KB |
Output is correct |
51 |
Correct |
0 ms |
348 KB |
Output is correct |
52 |
Correct |
0 ms |
348 KB |
Output is correct |
53 |
Correct |
0 ms |
348 KB |
Output is correct |
54 |
Correct |
0 ms |
348 KB |
Output is correct |
55 |
Correct |
0 ms |
348 KB |
Output is correct |
56 |
Correct |
0 ms |
348 KB |
Output is correct |
57 |
Correct |
0 ms |
348 KB |
Output is correct |
58 |
Correct |
0 ms |
348 KB |
Output is correct |
59 |
Correct |
0 ms |
348 KB |
Output is correct |
60 |
Correct |
0 ms |
348 KB |
Output is correct |
61 |
Correct |
0 ms |
348 KB |
Output is correct |
62 |
Correct |
0 ms |
348 KB |
Output is correct |
63 |
Correct |
0 ms |
452 KB |
Output is correct |
64 |
Correct |
0 ms |
348 KB |
Output is correct |
65 |
Correct |
0 ms |
456 KB |
Output is correct |
66 |
Correct |
38 ms |
19144 KB |
Output is correct |
67 |
Correct |
28 ms |
19152 KB |
Output is correct |
68 |
Correct |
64 ms |
30220 KB |
Output is correct |
69 |
Correct |
38 ms |
24276 KB |
Output is correct |
70 |
Correct |
40 ms |
24164 KB |
Output is correct |
71 |
Correct |
50 ms |
30448 KB |
Output is correct |
72 |
Correct |
50 ms |
29748 KB |
Output is correct |
73 |
Correct |
84 ms |
30208 KB |
Output is correct |
74 |
Correct |
51 ms |
28424 KB |
Output is correct |
75 |
Correct |
72 ms |
26372 KB |
Output is correct |
76 |
Correct |
43 ms |
23180 KB |
Output is correct |
77 |
Correct |
39 ms |
22240 KB |
Output is correct |
78 |
Correct |
36 ms |
21816 KB |
Output is correct |
79 |
Correct |
56 ms |
22020 KB |
Output is correct |
80 |
Correct |
49 ms |
19720 KB |
Output is correct |
81 |
Correct |
37 ms |
19208 KB |
Output is correct |
82 |
Correct |
3 ms |
4324 KB |
Output is correct |
83 |
Correct |
2 ms |
4324 KB |
Output is correct |
84 |
Correct |
3 ms |
4352 KB |
Output is correct |
85 |
Correct |
2 ms |
4324 KB |
Output is correct |
86 |
Correct |
3 ms |
4316 KB |
Output is correct |
87 |
Correct |
2 ms |
4316 KB |
Output is correct |
88 |
Correct |
1 ms |
600 KB |
Output is correct |
89 |
Correct |
1 ms |
604 KB |
Output is correct |
90 |
Correct |
1 ms |
604 KB |
Output is correct |
91 |
Correct |
2 ms |
860 KB |
Output is correct |
92 |
Correct |
1 ms |
860 KB |
Output is correct |
93 |
Correct |
1 ms |
860 KB |
Output is correct |
94 |
Correct |
1 ms |
860 KB |
Output is correct |
95 |
Correct |
1 ms |
860 KB |
Output is correct |
96 |
Correct |
1 ms |
604 KB |
Output is correct |
97 |
Correct |
1 ms |
604 KB |
Output is correct |
98 |
Correct |
1 ms |
604 KB |
Output is correct |
99 |
Correct |
1 ms |
604 KB |
Output is correct |
100 |
Correct |
1 ms |
604 KB |
Output is correct |
101 |
Correct |
1 ms |
604 KB |
Output is correct |
102 |
Correct |
0 ms |
604 KB |
Output is correct |
103 |
Correct |
1 ms |
604 KB |
Output is correct |
104 |
Correct |
1 ms |
604 KB |
Output is correct |
105 |
Correct |
1 ms |
604 KB |
Output is correct |
106 |
Correct |
0 ms |
604 KB |
Output is correct |
107 |
Correct |
1 ms |
604 KB |
Output is correct |
108 |
Correct |
56 ms |
35648 KB |
Output is correct |
109 |
Correct |
64 ms |
33276 KB |
Output is correct |
110 |
Correct |
57 ms |
35580 KB |
Output is correct |
111 |
Correct |
73 ms |
33660 KB |
Output is correct |
112 |
Correct |
88 ms |
34252 KB |
Output is correct |
113 |
Correct |
69 ms |
48116 KB |
Output is correct |
114 |
Correct |
73 ms |
44280 KB |
Output is correct |
115 |
Correct |
63 ms |
43256 KB |
Output is correct |
116 |
Correct |
69 ms |
41460 KB |
Output is correct |
117 |
Correct |
56 ms |
33536 KB |
Output is correct |
118 |
Correct |
54 ms |
33020 KB |
Output is correct |
119 |
Correct |
90 ms |
36852 KB |
Output is correct |
120 |
Correct |
58 ms |
35328 KB |
Output is correct |
121 |
Correct |
55 ms |
32252 KB |
Output is correct |
122 |
Correct |
74 ms |
32000 KB |
Output is correct |
123 |
Correct |
35 ms |
21508 KB |
Output is correct |
124 |
Correct |
34 ms |
27196 KB |
Output is correct |
125 |
Correct |
44 ms |
28412 KB |
Output is correct |
126 |
Correct |
35 ms |
27460 KB |
Output is correct |
127 |
Correct |
35 ms |
27800 KB |
Output is correct |
128 |
Correct |
1 ms |
600 KB |
Output is correct |
129 |
Correct |
1 ms |
604 KB |
Output is correct |
130 |
Correct |
1 ms |
604 KB |
Output is correct |
131 |
Correct |
1 ms |
604 KB |
Output is correct |
132 |
Correct |
1 ms |
604 KB |
Output is correct |
133 |
Correct |
1 ms |
604 KB |
Output is correct |
134 |
Correct |
1 ms |
604 KB |
Output is correct |
135 |
Correct |
1 ms |
604 KB |
Output is correct |
136 |
Correct |
1 ms |
348 KB |
Output is correct |
137 |
Correct |
0 ms |
348 KB |
Output is correct |
138 |
Correct |
1 ms |
348 KB |
Output is correct |
139 |
Correct |
1 ms |
720 KB |
Output is correct |
140 |
Correct |
1 ms |
604 KB |
Output is correct |
141 |
Correct |
1 ms |
604 KB |
Output is correct |
142 |
Correct |
1 ms |
856 KB |
Output is correct |
143 |
Correct |
0 ms |
604 KB |
Output is correct |
144 |
Correct |
1 ms |
644 KB |
Output is correct |
145 |
Correct |
0 ms |
604 KB |
Output is correct |
146 |
Correct |
1 ms |
604 KB |
Output is correct |
147 |
Correct |
1 ms |
604 KB |
Output is correct |
148 |
Correct |
1 ms |
604 KB |
Output is correct |
149 |
Correct |
1 ms |
604 KB |
Output is correct |
150 |
Correct |
1 ms |
604 KB |
Output is correct |
151 |
Correct |
1 ms |
604 KB |
Output is correct |
152 |
Correct |
0 ms |
348 KB |
Output is correct |
153 |
Correct |
0 ms |
348 KB |
Output is correct |
154 |
Correct |
0 ms |
348 KB |
Output is correct |
155 |
Correct |
58 ms |
36100 KB |
Output is correct |
156 |
Correct |
71 ms |
34584 KB |
Output is correct |
157 |
Correct |
90 ms |
33620 KB |
Output is correct |
158 |
Correct |
52 ms |
26124 KB |
Output is correct |
159 |
Correct |
38 ms |
19208 KB |
Output is correct |
160 |
Correct |
36 ms |
16248 KB |
Output is correct |
161 |
Correct |
32 ms |
14856 KB |
Output is correct |
162 |
Correct |
32 ms |
12936 KB |
Output is correct |
163 |
Correct |
41 ms |
12060 KB |
Output is correct |
164 |
Correct |
30 ms |
11488 KB |
Output is correct |
165 |
Correct |
26 ms |
10588 KB |
Output is correct |
166 |
Correct |
38 ms |
9708 KB |
Output is correct |
167 |
Correct |
26 ms |
9780 KB |
Output is correct |
168 |
Correct |
30 ms |
12328 KB |
Output is correct |
169 |
Correct |
61 ms |
40528 KB |
Output is correct |
170 |
Correct |
63 ms |
39420 KB |
Output is correct |
171 |
Correct |
56 ms |
37504 KB |
Output is correct |
172 |
Correct |
61 ms |
33032 KB |
Output is correct |
173 |
Correct |
54 ms |
25844 KB |
Output is correct |
174 |
Correct |
49 ms |
25772 KB |
Output is correct |
175 |
Correct |
49 ms |
25776 KB |
Output is correct |
176 |
Correct |
70 ms |
24104 KB |
Output is correct |
177 |
Correct |
38 ms |
21708 KB |
Output is correct |
178 |
Correct |
46 ms |
29768 KB |
Output is correct |
179 |
Correct |
58 ms |
30068 KB |
Output is correct |
180 |
Correct |
55 ms |
26976 KB |
Output is correct |
181 |
Correct |
79 ms |
28420 KB |
Output is correct |
182 |
Correct |
1 ms |
348 KB |
Output is correct |
183 |
Correct |
1 ms |
604 KB |
Output is correct |
184 |
Correct |
1 ms |
604 KB |
Output is correct |
185 |
Correct |
1 ms |
468 KB |
Output is correct |
186 |
Correct |
0 ms |
604 KB |
Output is correct |
187 |
Correct |
0 ms |
604 KB |
Output is correct |
188 |
Correct |
0 ms |
604 KB |
Output is correct |
189 |
Correct |
0 ms |
604 KB |
Output is correct |
190 |
Correct |
1 ms |
456 KB |
Output is correct |
191 |
Correct |
1 ms |
604 KB |
Output is correct |
192 |
Correct |
1 ms |
348 KB |
Output is correct |
193 |
Correct |
1 ms |
716 KB |
Output is correct |
194 |
Correct |
1 ms |
644 KB |
Output is correct |
195 |
Correct |
1 ms |
348 KB |
Output is correct |
196 |
Correct |
0 ms |
348 KB |
Output is correct |
197 |
Correct |
0 ms |
460 KB |
Output is correct |
198 |
Correct |
1 ms |
604 KB |
Output is correct |
199 |
Correct |
1 ms |
604 KB |
Output is correct |
200 |
Correct |
1 ms |
604 KB |
Output is correct |
201 |
Correct |
0 ms |
604 KB |
Output is correct |
202 |
Correct |
1 ms |
604 KB |
Output is correct |
203 |
Correct |
1 ms |
604 KB |
Output is correct |
204 |
Correct |
1 ms |
604 KB |
Output is correct |
205 |
Correct |
1 ms |
604 KB |
Output is correct |
206 |
Correct |
1 ms |
604 KB |
Output is correct |
207 |
Correct |
0 ms |
604 KB |
Output is correct |
208 |
Correct |
0 ms |
604 KB |
Output is correct |
209 |
Correct |
2 ms |
4316 KB |
Output is correct |
210 |
Correct |
35 ms |
21316 KB |
Output is correct |
211 |
Correct |
46 ms |
24400 KB |
Output is correct |
212 |
Correct |
50 ms |
20588 KB |
Output is correct |
213 |
Correct |
76 ms |
20340 KB |
Output is correct |
214 |
Correct |
55 ms |
21288 KB |
Output is correct |
215 |
Correct |
30 ms |
17924 KB |
Output is correct |
216 |
Correct |
48 ms |
28164 KB |
Output is correct |
217 |
Correct |
42 ms |
19464 KB |
Output is correct |
218 |
Correct |
36 ms |
12800 KB |
Output is correct |
219 |
Correct |
27 ms |
11252 KB |
Output is correct |
220 |
Correct |
24 ms |
10332 KB |
Output is correct |
221 |
Correct |
23 ms |
9596 KB |
Output is correct |
222 |
Correct |
22 ms |
11040 KB |
Output is correct |
223 |
Correct |
48 ms |
24836 KB |
Output is correct |
224 |
Correct |
48 ms |
23808 KB |
Output is correct |
225 |
Correct |
46 ms |
17868 KB |
Output is correct |
226 |
Correct |
40 ms |
18060 KB |
Output is correct |
227 |
Correct |
43 ms |
17924 KB |
Output is correct |
228 |
Correct |
38 ms |
17668 KB |
Output is correct |
229 |
Correct |
53 ms |
16900 KB |
Output is correct |
230 |
Correct |
39 ms |
17160 KB |
Output is correct |
231 |
Correct |
60 ms |
17160 KB |
Output is correct |