#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>
struct graph{
using Weight_t = T;
struct Edge_t{
int from, to;
T cost;
};
int n;
vector<Edge_t> edge;
vector<vector<int>> adj;
function<bool(int)> ignore;
graph(int n = 1): n(n), adj(n){
assert(n >= 1);
}
graph(const vector<vector<int>> &adj, bool undirected = true): n((int)adj.size()), adj(n){
assert(n >= 1);
if(undirected){
for(auto u = 0; u < n; ++ u) for(auto v: adj[u]) if(u < v) link(u, v);
}
else for(auto u = 0; u < n; ++ u) for(auto v: adj[u]) orient(u, v);
}
graph(const vector<vector<pair<int, T>>> &adj, bool undirected = true): n((int)adj.size()), adj(n){
assert(n >= 1);
if(undirected){
for(auto u = 0; u < n; ++ u) for(auto [v, w]: adj[u]) if(u < v) link(u, v, w);
}
else for(auto u = 0; u < n; ++ u) for(auto [v, w]: adj[u]) orient(u, v, w);
}
graph(int n, vector<array<int, 2>> &edge, bool undirected = true): n(n), adj(n){
assert(n >= 1);
for(auto [u, v]: edge) undirected ? link(u, v) : orient(u, v);
}
graph(int n, vector<tuple<int, int, T>> &edge, bool undirected = true): n(n), adj(n){
assert(n >= 1);
for(auto [u, v, w]: edge) undirected ? link(u, v, w) : orient(u, v, w);
}
int operator()(int u, int id) const{
#ifdef LOCAL
assert(0 <= id && id < (int)edge.size());
assert(edge[id].from == u || edge[id].to == u);
#endif
return u ^ edge[id].from ^ edge[id].to;
}
int link(int u, int v, T w = {}){ // insert an undirected edge
int id = (int)edge.size();
adj[u].push_back(id), adj[v].push_back(id), edge.push_back({u, v, w});
return id;
}
int orient(int u, int v, T w = {}){ // insert a directed edge
int id = (int)edge.size();
adj[u].push_back(id), edge.push_back({u, v, w});
return id;
}
void clear(){
for(auto [u, v, w]: edge){
adj[u].clear();
adj[v].clear();
}
edge.clear();
ignore = {};
}
graph transpose() const{ // the transpose of the directed graph
graph res(n);
for(auto id = 0; id < (int)edge.size(); ++ id){
if(ignore && ignore(id)) continue;
res.orient(edge[id].to, edge[id].from, edge[id].cost);
}
return res;
}
int degree(int u) const{ // the degree (outdegree if directed) of u (without the ignoration rule)
return (int)adj[u].size();
}
// The adjacency list is sorted for each vertex.
vector<vector<int>> get_adjacency_list() const{
vector<vector<int>> res(n);
for(auto u = 0; u < n; ++ u) for(auto id: adj[u]){
if(ignore && ignore(id)) continue;
res[(*this)(u, id)].push_back(u);
}
return res;
}
void set_ignoration_rule(const function<bool(int)> &f){
ignore = f;
}
void reset_ignoration_rule(){
ignore = nullptr;
}
friend ostream &operator<<(ostream &out, const graph &g){
for(auto id = 0; id < (int)g.edge.size(); ++ id){
if(g.ignore && g.ignore(id)) continue;
auto &e = g.edge[id];
out << "{" << e.from << ", " << e.to << ", " << e.cost << "}\n";
}
return out;
}
};
// Requires graph
struct biconnected_components{
int n, attempt, comp_attempt;
vector<int> pos;
vector<int> stack;
vector<int> was;
vector<int> comp_was;
// block-cut tree descriptions
vector<vector<int>> belongs; // vertex -> list of 2-vertex-connected components
vector<vector<int>> comp_vertex; // list of vertices in a 2-vertex-connected component
vector<vector<int>> comp_edge; // list of edges in a 2-vertex-connected component
vector<int> bridge;
biconnected_components(){ }
biconnected_components(int n){ init(n); }
template<class T>
biconnected_components(const graph<T> &g){ init(g.n); run_all(g); }
void init(int n){
this->n = n;
pos.assign(n, -1);
was.assign(n, -2);
attempt = -1;
comp_was.assign(n, -2);
comp_attempt = -1;
belongs.assign(n, {});
comp_vertex.clear();
comp_edge.clear();
bridge.clear();
}
// O(n + m) where n and m are the number of reachable nodes and edges respectively.
template<class T>
void _run(const graph<T> &g, const vector<int> &src){
int it = 0;
auto recurse = [&](auto self, int u, int pe)->int{
int low = pos[u] = ++ it;
belongs[u].clear();
was[u] = attempt;
for(auto id: g.adj[u]){
if(g.ignore && g.ignore(id) || id == pe) continue;
int v = g(u, id);
if(was[v] != attempt){
was[v] = attempt;
pos[v] = 0;
}
if(pos[v]){
low = min(low, pos[v]);
if(pos[v] < pos[u]) stack.push_back(id);
}
else{
int size = (int)stack.size(), up = self(self, v, id);
low = min(low, up);
if(up == pos[u]){
++ comp_attempt;
stack.push_back(id);
vector<int> comp_v;
vector<int> comp_e(stack.begin() + size, stack.end());
for(auto id: comp_e){
auto [u, v, _] = g.edge[id];
if(comp_was[u] != comp_attempt){
comp_was[u] = comp_attempt;
comp_v.push_back(u);
}
if(comp_was[v] != comp_attempt){
comp_was[v] = comp_attempt;
comp_v.push_back(v);
}
}
for(auto u: comp_v) belongs[u].push_back((int)comp_vertex.size());
comp_vertex.push_back(move(comp_v));
comp_edge.push_back(move(comp_e));
stack.resize(size);
}
else if(up < pos[u]) stack.push_back(id);
else{
belongs[g.edge[id].from].push_back((int)comp_vertex.size());
belongs[g.edge[id].to].push_back((int)comp_vertex.size());
comp_vertex.push_back({g.edge[id].from, g.edge[id].to});
comp_edge.push_back({id});
bridge.push_back(id);
}
}
}
return low;
};
for(auto u: src) if(was[u] != attempt) recurse(recurse, u, -1);
}
template<class T>
void run(const graph<T> &g, const vector<int> &src){
assert(g.n <= n);
for(auto u: src) assert(0 <= u && u < g.n);
comp_vertex.clear();
comp_edge.clear();
bridge.clear();
++ attempt;
_run(g, src);
}
template<class T>
void run_all(const graph<T> &g){
assert(g.n <= n);
comp_vertex.clear();
comp_edge.clear();
bridge.clear();
++ attempt;
vector<int> src(g.n);
iota(src.begin(), src.end(), 0);
_run(g, src);
}
// Check if u is visited during the last run-like call.
bool visited(int u) const{
assert(0 <= u && u < n);
return was[u] == attempt;
}
bool is_articulation_point(int u) const{
assert(0 <= u && u < n && visited(n));
return (int)belongs[u].size() >= 2;
}
bool is_bridge_component(int i) const{
assert(0 <= i && i < (int)comp_vertex.size());
return (int)comp_edge[i].size() == 1;
}
// # of 2-vertex-connected components
int count() const{
return (int)comp_vertex.size();
}
};
int n, visited[300300];
ll ans, dp0[300300], dp[300300];
vector<int> adj[300300];
int dfs1(int s, int pa = -1){
visited[s] = 1;
if (s < n) dp[s] = 1;
for (auto &v:adj[s]) if (v!=pa){
dp[s] += dfs1(v, s) - 1;
}
return dp[s];
}
void dfs2(int nn, int s, int pa = -1){
for (auto &v:adj[s]) if (v!=pa) dfs2(nn, v, s);
if (s < n) return;
ll rem = nn - dp0[s];
for (auto &v:adj[s]) if (v!=pa){
ans -= (dp0[s]-1) * dp[v] * (dp[v]-1);
rem -= dp[v]-1;
}
rem++;
ans -= (dp0[s]-1) * rem * (rem-1);
}
int main(){
int m;
scanf("%d %d", &n, &m);
vector<array<int, 2>> E;
for (int i=0;i<m;i++){
int x, y;
scanf("%d %d", &x, &y);
--x, --y;
E.push_back({x, y});
}
graph<int> G(n, E);
biconnected_components BCC(G);
int sz = n + BCC.count();
for (int i=0;i<n;i++){
for (auto &x:BCC.belongs[i]){
assert(n+x < sz);
adj[i].push_back(n+x);
adj[n+x].push_back(i);
}
}
for (int i=0;i<sz;i++){
if (i<n) dp0[i] = dp[i] = 1;
else dp0[i] = dp[i] = BCC.comp_vertex[i-n].size();
}
for (int i=0;i<sz;i++) if (!visited[i]){
ll v = dfs1(i);
if (v <= 2) continue;
ans += v * (v-1) * (v-2);
dfs2(v, i);
}
printf("%lld\n", ans);
}
Compilation message
count_triplets.cpp: In instantiation of 'biconnected_components::_run<int>::<lambda(auto:23, int, int)> [with auto:23 = biconnected_components::_run<int>::<lambda(auto:23, int, int)>]':
count_triplets.cpp:186:42: required from 'void biconnected_components::_run(const graph<T>&, const std::vector<int>&) [with T = int]'
count_triplets.cpp:207:7: required from 'void biconnected_components::run_all(const graph<T>&) [with T = int]'
count_triplets.cpp:118:63: required from 'biconnected_components::biconnected_components(const graph<T>&) [with T = int]'
count_triplets.cpp:271:30: required from here
count_triplets.cpp:140:17: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
140 | if(g.ignore && g.ignore(id) || id == pe) continue;
| ~~~~~~~~~^~~~~~~~~~~~~~~
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:259:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
259 | scanf("%d %d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~~
count_triplets.cpp:265:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
265 | scanf("%d %d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
2 ms |
10844 KB |
Output is correct |
3 |
Correct |
2 ms |
10840 KB |
Output is correct |
4 |
Correct |
2 ms |
10844 KB |
Output is correct |
5 |
Correct |
3 ms |
10864 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
2 ms |
10844 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
3 ms |
10844 KB |
Output is correct |
10 |
Correct |
3 ms |
10844 KB |
Output is correct |
11 |
Correct |
2 ms |
10844 KB |
Output is correct |
12 |
Correct |
2 ms |
10840 KB |
Output is correct |
13 |
Correct |
3 ms |
10844 KB |
Output is correct |
14 |
Correct |
2 ms |
10844 KB |
Output is correct |
15 |
Correct |
3 ms |
10844 KB |
Output is correct |
16 |
Correct |
2 ms |
10844 KB |
Output is correct |
17 |
Correct |
3 ms |
10844 KB |
Output is correct |
18 |
Correct |
2 ms |
10844 KB |
Output is correct |
19 |
Correct |
2 ms |
10844 KB |
Output is correct |
20 |
Correct |
2 ms |
10844 KB |
Output is correct |
21 |
Correct |
2 ms |
10844 KB |
Output is correct |
22 |
Correct |
2 ms |
10844 KB |
Output is correct |
23 |
Correct |
2 ms |
10860 KB |
Output is correct |
24 |
Correct |
2 ms |
10840 KB |
Output is correct |
25 |
Correct |
2 ms |
10868 KB |
Output is correct |
26 |
Correct |
2 ms |
10840 KB |
Output is correct |
27 |
Correct |
3 ms |
10844 KB |
Output is correct |
28 |
Correct |
2 ms |
10844 KB |
Output is correct |
29 |
Correct |
2 ms |
10844 KB |
Output is correct |
30 |
Correct |
2 ms |
10844 KB |
Output is correct |
31 |
Correct |
3 ms |
11096 KB |
Output is correct |
32 |
Correct |
2 ms |
10868 KB |
Output is correct |
33 |
Correct |
2 ms |
10840 KB |
Output is correct |
34 |
Correct |
2 ms |
10840 KB |
Output is correct |
35 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
2 ms |
10844 KB |
Output is correct |
3 |
Correct |
2 ms |
10840 KB |
Output is correct |
4 |
Correct |
2 ms |
10844 KB |
Output is correct |
5 |
Correct |
3 ms |
10864 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
2 ms |
10844 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
3 ms |
10844 KB |
Output is correct |
10 |
Correct |
3 ms |
10844 KB |
Output is correct |
11 |
Correct |
2 ms |
10844 KB |
Output is correct |
12 |
Correct |
2 ms |
10840 KB |
Output is correct |
13 |
Correct |
3 ms |
10844 KB |
Output is correct |
14 |
Correct |
2 ms |
10844 KB |
Output is correct |
15 |
Correct |
3 ms |
10844 KB |
Output is correct |
16 |
Correct |
2 ms |
10844 KB |
Output is correct |
17 |
Correct |
3 ms |
10844 KB |
Output is correct |
18 |
Correct |
2 ms |
10844 KB |
Output is correct |
19 |
Correct |
2 ms |
10844 KB |
Output is correct |
20 |
Correct |
2 ms |
10844 KB |
Output is correct |
21 |
Correct |
2 ms |
10844 KB |
Output is correct |
22 |
Correct |
2 ms |
10844 KB |
Output is correct |
23 |
Correct |
2 ms |
10860 KB |
Output is correct |
24 |
Correct |
2 ms |
10840 KB |
Output is correct |
25 |
Correct |
2 ms |
10868 KB |
Output is correct |
26 |
Correct |
2 ms |
10840 KB |
Output is correct |
27 |
Correct |
3 ms |
10844 KB |
Output is correct |
28 |
Correct |
2 ms |
10844 KB |
Output is correct |
29 |
Correct |
2 ms |
10844 KB |
Output is correct |
30 |
Correct |
2 ms |
10844 KB |
Output is correct |
31 |
Correct |
3 ms |
11096 KB |
Output is correct |
32 |
Correct |
2 ms |
10868 KB |
Output is correct |
33 |
Correct |
2 ms |
10840 KB |
Output is correct |
34 |
Correct |
2 ms |
10840 KB |
Output is correct |
35 |
Correct |
2 ms |
10844 KB |
Output is correct |
36 |
Correct |
2 ms |
10844 KB |
Output is correct |
37 |
Correct |
3 ms |
10844 KB |
Output is correct |
38 |
Correct |
2 ms |
10844 KB |
Output is correct |
39 |
Correct |
3 ms |
10904 KB |
Output is correct |
40 |
Correct |
2 ms |
10844 KB |
Output is correct |
41 |
Correct |
3 ms |
10840 KB |
Output is correct |
42 |
Correct |
2 ms |
10840 KB |
Output is correct |
43 |
Correct |
2 ms |
10844 KB |
Output is correct |
44 |
Correct |
2 ms |
10844 KB |
Output is correct |
45 |
Correct |
2 ms |
10840 KB |
Output is correct |
46 |
Correct |
3 ms |
10844 KB |
Output is correct |
47 |
Correct |
3 ms |
10856 KB |
Output is correct |
48 |
Correct |
3 ms |
10844 KB |
Output is correct |
49 |
Correct |
2 ms |
10844 KB |
Output is correct |
50 |
Correct |
2 ms |
10844 KB |
Output is correct |
51 |
Correct |
2 ms |
10840 KB |
Output is correct |
52 |
Correct |
2 ms |
10844 KB |
Output is correct |
53 |
Correct |
2 ms |
10844 KB |
Output is correct |
54 |
Correct |
2 ms |
11096 KB |
Output is correct |
55 |
Correct |
2 ms |
10840 KB |
Output is correct |
56 |
Correct |
2 ms |
10864 KB |
Output is correct |
57 |
Correct |
2 ms |
10844 KB |
Output is correct |
58 |
Correct |
2 ms |
10844 KB |
Output is correct |
59 |
Correct |
3 ms |
11100 KB |
Output is correct |
60 |
Correct |
2 ms |
10844 KB |
Output is correct |
61 |
Correct |
2 ms |
10844 KB |
Output is correct |
62 |
Correct |
2 ms |
10844 KB |
Output is correct |
63 |
Correct |
2 ms |
10840 KB |
Output is correct |
64 |
Correct |
3 ms |
10844 KB |
Output is correct |
65 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
82 ms |
54896 KB |
Output is correct |
2 |
Correct |
83 ms |
54980 KB |
Output is correct |
3 |
Correct |
106 ms |
50628 KB |
Output is correct |
4 |
Correct |
92 ms |
53216 KB |
Output is correct |
5 |
Correct |
93 ms |
45752 KB |
Output is correct |
6 |
Correct |
118 ms |
48504 KB |
Output is correct |
7 |
Correct |
123 ms |
45796 KB |
Output is correct |
8 |
Correct |
124 ms |
47896 KB |
Output is correct |
9 |
Correct |
102 ms |
43192 KB |
Output is correct |
10 |
Correct |
102 ms |
44224 KB |
Output is correct |
11 |
Correct |
78 ms |
38084 KB |
Output is correct |
12 |
Correct |
74 ms |
37560 KB |
Output is correct |
13 |
Correct |
72 ms |
37048 KB |
Output is correct |
14 |
Correct |
67 ms |
36544 KB |
Output is correct |
15 |
Correct |
51 ms |
34012 KB |
Output is correct |
16 |
Correct |
74 ms |
33596 KB |
Output is correct |
17 |
Correct |
9 ms |
17108 KB |
Output is correct |
18 |
Correct |
12 ms |
17032 KB |
Output is correct |
19 |
Correct |
13 ms |
17360 KB |
Output is correct |
20 |
Correct |
8 ms |
17108 KB |
Output is correct |
21 |
Correct |
7 ms |
17108 KB |
Output is correct |
22 |
Correct |
8 ms |
16992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
11100 KB |
Output is correct |
2 |
Correct |
3 ms |
11100 KB |
Output is correct |
3 |
Correct |
4 ms |
11024 KB |
Output is correct |
4 |
Correct |
3 ms |
11352 KB |
Output is correct |
5 |
Correct |
3 ms |
11096 KB |
Output is correct |
6 |
Correct |
3 ms |
11100 KB |
Output is correct |
7 |
Correct |
3 ms |
11100 KB |
Output is correct |
8 |
Correct |
3 ms |
11096 KB |
Output is correct |
9 |
Correct |
4 ms |
11096 KB |
Output is correct |
10 |
Correct |
4 ms |
11096 KB |
Output is correct |
11 |
Correct |
3 ms |
11100 KB |
Output is correct |
12 |
Correct |
4 ms |
11128 KB |
Output is correct |
13 |
Correct |
3 ms |
11096 KB |
Output is correct |
14 |
Correct |
3 ms |
11100 KB |
Output is correct |
15 |
Correct |
3 ms |
11160 KB |
Output is correct |
16 |
Correct |
4 ms |
10868 KB |
Output is correct |
17 |
Correct |
4 ms |
11136 KB |
Output is correct |
18 |
Correct |
3 ms |
11100 KB |
Output is correct |
19 |
Correct |
4 ms |
11100 KB |
Output is correct |
20 |
Correct |
3 ms |
11100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
45668 KB |
Output is correct |
2 |
Correct |
135 ms |
44972 KB |
Output is correct |
3 |
Correct |
130 ms |
45084 KB |
Output is correct |
4 |
Correct |
158 ms |
44992 KB |
Output is correct |
5 |
Correct |
157 ms |
45588 KB |
Output is correct |
6 |
Correct |
185 ms |
58356 KB |
Output is correct |
7 |
Correct |
177 ms |
54028 KB |
Output is correct |
8 |
Correct |
168 ms |
51268 KB |
Output is correct |
9 |
Correct |
184 ms |
49084 KB |
Output is correct |
10 |
Correct |
150 ms |
45488 KB |
Output is correct |
11 |
Correct |
184 ms |
46596 KB |
Output is correct |
12 |
Correct |
164 ms |
46384 KB |
Output is correct |
13 |
Correct |
179 ms |
46196 KB |
Output is correct |
14 |
Correct |
108 ms |
44708 KB |
Output is correct |
15 |
Correct |
104 ms |
42036 KB |
Output is correct |
16 |
Correct |
57 ms |
34732 KB |
Output is correct |
17 |
Correct |
109 ms |
46980 KB |
Output is correct |
18 |
Correct |
98 ms |
47288 KB |
Output is correct |
19 |
Correct |
103 ms |
47280 KB |
Output is correct |
20 |
Correct |
102 ms |
47172 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
11096 KB |
Output is correct |
2 |
Correct |
3 ms |
11100 KB |
Output is correct |
3 |
Correct |
4 ms |
11096 KB |
Output is correct |
4 |
Correct |
4 ms |
11100 KB |
Output is correct |
5 |
Correct |
3 ms |
11096 KB |
Output is correct |
6 |
Correct |
3 ms |
11100 KB |
Output is correct |
7 |
Correct |
3 ms |
11096 KB |
Output is correct |
8 |
Correct |
3 ms |
11100 KB |
Output is correct |
9 |
Correct |
3 ms |
11096 KB |
Output is correct |
10 |
Correct |
2 ms |
11100 KB |
Output is correct |
11 |
Correct |
2 ms |
11100 KB |
Output is correct |
12 |
Correct |
3 ms |
11100 KB |
Output is correct |
13 |
Correct |
3 ms |
11100 KB |
Output is correct |
14 |
Correct |
3 ms |
11100 KB |
Output is correct |
15 |
Correct |
3 ms |
11100 KB |
Output is correct |
16 |
Correct |
3 ms |
11100 KB |
Output is correct |
17 |
Correct |
3 ms |
11096 KB |
Output is correct |
18 |
Correct |
3 ms |
11100 KB |
Output is correct |
19 |
Correct |
3 ms |
11096 KB |
Output is correct |
20 |
Correct |
3 ms |
11352 KB |
Output is correct |
21 |
Correct |
4 ms |
11204 KB |
Output is correct |
22 |
Correct |
3 ms |
11100 KB |
Output is correct |
23 |
Correct |
3 ms |
11096 KB |
Output is correct |
24 |
Correct |
3 ms |
11100 KB |
Output is correct |
25 |
Correct |
2 ms |
10844 KB |
Output is correct |
26 |
Correct |
3 ms |
10968 KB |
Output is correct |
27 |
Correct |
2 ms |
10840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
141 ms |
45288 KB |
Output is correct |
2 |
Correct |
126 ms |
44724 KB |
Output is correct |
3 |
Correct |
119 ms |
43196 KB |
Output is correct |
4 |
Correct |
114 ms |
39296 KB |
Output is correct |
5 |
Correct |
93 ms |
36036 KB |
Output is correct |
6 |
Correct |
90 ms |
33216 KB |
Output is correct |
7 |
Correct |
85 ms |
32648 KB |
Output is correct |
8 |
Correct |
74 ms |
31676 KB |
Output is correct |
9 |
Correct |
71 ms |
31396 KB |
Output is correct |
10 |
Correct |
88 ms |
31184 KB |
Output is correct |
11 |
Correct |
74 ms |
30660 KB |
Output is correct |
12 |
Correct |
75 ms |
30656 KB |
Output is correct |
13 |
Correct |
81 ms |
30892 KB |
Output is correct |
14 |
Correct |
76 ms |
36492 KB |
Output is correct |
15 |
Correct |
167 ms |
53336 KB |
Output is correct |
16 |
Correct |
178 ms |
49852 KB |
Output is correct |
17 |
Correct |
163 ms |
50936 KB |
Output is correct |
18 |
Correct |
161 ms |
48156 KB |
Output is correct |
19 |
Correct |
107 ms |
39216 KB |
Output is correct |
20 |
Correct |
106 ms |
40896 KB |
Output is correct |
21 |
Correct |
116 ms |
40796 KB |
Output is correct |
22 |
Correct |
92 ms |
38852 KB |
Output is correct |
23 |
Correct |
82 ms |
37060 KB |
Output is correct |
24 |
Correct |
119 ms |
44768 KB |
Output is correct |
25 |
Correct |
141 ms |
45492 KB |
Output is correct |
26 |
Correct |
119 ms |
42940 KB |
Output is correct |
27 |
Correct |
123 ms |
43960 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
2 ms |
10844 KB |
Output is correct |
3 |
Correct |
2 ms |
10840 KB |
Output is correct |
4 |
Correct |
2 ms |
10844 KB |
Output is correct |
5 |
Correct |
3 ms |
10864 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
2 ms |
10844 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
3 ms |
10844 KB |
Output is correct |
10 |
Correct |
3 ms |
10844 KB |
Output is correct |
11 |
Correct |
2 ms |
10844 KB |
Output is correct |
12 |
Correct |
2 ms |
10840 KB |
Output is correct |
13 |
Correct |
3 ms |
10844 KB |
Output is correct |
14 |
Correct |
2 ms |
10844 KB |
Output is correct |
15 |
Correct |
3 ms |
10844 KB |
Output is correct |
16 |
Correct |
2 ms |
10844 KB |
Output is correct |
17 |
Correct |
3 ms |
10844 KB |
Output is correct |
18 |
Correct |
2 ms |
10844 KB |
Output is correct |
19 |
Correct |
2 ms |
10844 KB |
Output is correct |
20 |
Correct |
2 ms |
10844 KB |
Output is correct |
21 |
Correct |
2 ms |
10844 KB |
Output is correct |
22 |
Correct |
2 ms |
10844 KB |
Output is correct |
23 |
Correct |
2 ms |
10860 KB |
Output is correct |
24 |
Correct |
2 ms |
10840 KB |
Output is correct |
25 |
Correct |
2 ms |
10868 KB |
Output is correct |
26 |
Correct |
2 ms |
10840 KB |
Output is correct |
27 |
Correct |
3 ms |
10844 KB |
Output is correct |
28 |
Correct |
2 ms |
10844 KB |
Output is correct |
29 |
Correct |
2 ms |
10844 KB |
Output is correct |
30 |
Correct |
2 ms |
10844 KB |
Output is correct |
31 |
Correct |
3 ms |
11096 KB |
Output is correct |
32 |
Correct |
2 ms |
10868 KB |
Output is correct |
33 |
Correct |
2 ms |
10840 KB |
Output is correct |
34 |
Correct |
2 ms |
10840 KB |
Output is correct |
35 |
Correct |
2 ms |
10844 KB |
Output is correct |
36 |
Correct |
2 ms |
10844 KB |
Output is correct |
37 |
Correct |
3 ms |
10844 KB |
Output is correct |
38 |
Correct |
2 ms |
10844 KB |
Output is correct |
39 |
Correct |
3 ms |
10904 KB |
Output is correct |
40 |
Correct |
2 ms |
10844 KB |
Output is correct |
41 |
Correct |
3 ms |
10840 KB |
Output is correct |
42 |
Correct |
2 ms |
10840 KB |
Output is correct |
43 |
Correct |
2 ms |
10844 KB |
Output is correct |
44 |
Correct |
2 ms |
10844 KB |
Output is correct |
45 |
Correct |
2 ms |
10840 KB |
Output is correct |
46 |
Correct |
3 ms |
10844 KB |
Output is correct |
47 |
Correct |
3 ms |
10856 KB |
Output is correct |
48 |
Correct |
3 ms |
10844 KB |
Output is correct |
49 |
Correct |
2 ms |
10844 KB |
Output is correct |
50 |
Correct |
2 ms |
10844 KB |
Output is correct |
51 |
Correct |
2 ms |
10840 KB |
Output is correct |
52 |
Correct |
2 ms |
10844 KB |
Output is correct |
53 |
Correct |
2 ms |
10844 KB |
Output is correct |
54 |
Correct |
2 ms |
11096 KB |
Output is correct |
55 |
Correct |
2 ms |
10840 KB |
Output is correct |
56 |
Correct |
2 ms |
10864 KB |
Output is correct |
57 |
Correct |
2 ms |
10844 KB |
Output is correct |
58 |
Correct |
2 ms |
10844 KB |
Output is correct |
59 |
Correct |
3 ms |
11100 KB |
Output is correct |
60 |
Correct |
2 ms |
10844 KB |
Output is correct |
61 |
Correct |
2 ms |
10844 KB |
Output is correct |
62 |
Correct |
2 ms |
10844 KB |
Output is correct |
63 |
Correct |
2 ms |
10840 KB |
Output is correct |
64 |
Correct |
3 ms |
10844 KB |
Output is correct |
65 |
Correct |
2 ms |
10844 KB |
Output is correct |
66 |
Correct |
2 ms |
10844 KB |
Output is correct |
67 |
Correct |
3 ms |
11100 KB |
Output is correct |
68 |
Correct |
3 ms |
11100 KB |
Output is correct |
69 |
Correct |
3 ms |
11100 KB |
Output is correct |
70 |
Correct |
3 ms |
11100 KB |
Output is correct |
71 |
Correct |
3 ms |
11096 KB |
Output is correct |
72 |
Correct |
3 ms |
11096 KB |
Output is correct |
73 |
Correct |
3 ms |
11100 KB |
Output is correct |
74 |
Correct |
4 ms |
11100 KB |
Output is correct |
75 |
Correct |
3 ms |
11108 KB |
Output is correct |
76 |
Correct |
2 ms |
10864 KB |
Output is correct |
77 |
Correct |
3 ms |
11100 KB |
Output is correct |
78 |
Correct |
4 ms |
11096 KB |
Output is correct |
79 |
Correct |
3 ms |
11100 KB |
Output is correct |
80 |
Correct |
3 ms |
10928 KB |
Output is correct |
81 |
Correct |
2 ms |
11100 KB |
Output is correct |
82 |
Correct |
3 ms |
11100 KB |
Output is correct |
83 |
Correct |
3 ms |
11132 KB |
Output is correct |
84 |
Correct |
3 ms |
11096 KB |
Output is correct |
85 |
Correct |
3 ms |
11100 KB |
Output is correct |
86 |
Correct |
3 ms |
11100 KB |
Output is correct |
87 |
Correct |
3 ms |
11100 KB |
Output is correct |
88 |
Correct |
3 ms |
11096 KB |
Output is correct |
89 |
Correct |
3 ms |
11100 KB |
Output is correct |
90 |
Correct |
3 ms |
11100 KB |
Output is correct |
91 |
Correct |
3 ms |
11100 KB |
Output is correct |
92 |
Correct |
3 ms |
11352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
2 ms |
10844 KB |
Output is correct |
3 |
Correct |
2 ms |
10840 KB |
Output is correct |
4 |
Correct |
2 ms |
10844 KB |
Output is correct |
5 |
Correct |
3 ms |
10864 KB |
Output is correct |
6 |
Correct |
2 ms |
10844 KB |
Output is correct |
7 |
Correct |
2 ms |
10844 KB |
Output is correct |
8 |
Correct |
2 ms |
10844 KB |
Output is correct |
9 |
Correct |
3 ms |
10844 KB |
Output is correct |
10 |
Correct |
3 ms |
10844 KB |
Output is correct |
11 |
Correct |
2 ms |
10844 KB |
Output is correct |
12 |
Correct |
2 ms |
10840 KB |
Output is correct |
13 |
Correct |
3 ms |
10844 KB |
Output is correct |
14 |
Correct |
2 ms |
10844 KB |
Output is correct |
15 |
Correct |
3 ms |
10844 KB |
Output is correct |
16 |
Correct |
2 ms |
10844 KB |
Output is correct |
17 |
Correct |
3 ms |
10844 KB |
Output is correct |
18 |
Correct |
2 ms |
10844 KB |
Output is correct |
19 |
Correct |
2 ms |
10844 KB |
Output is correct |
20 |
Correct |
2 ms |
10844 KB |
Output is correct |
21 |
Correct |
2 ms |
10844 KB |
Output is correct |
22 |
Correct |
2 ms |
10844 KB |
Output is correct |
23 |
Correct |
2 ms |
10860 KB |
Output is correct |
24 |
Correct |
2 ms |
10840 KB |
Output is correct |
25 |
Correct |
2 ms |
10868 KB |
Output is correct |
26 |
Correct |
2 ms |
10840 KB |
Output is correct |
27 |
Correct |
3 ms |
10844 KB |
Output is correct |
28 |
Correct |
2 ms |
10844 KB |
Output is correct |
29 |
Correct |
2 ms |
10844 KB |
Output is correct |
30 |
Correct |
2 ms |
10844 KB |
Output is correct |
31 |
Correct |
3 ms |
11096 KB |
Output is correct |
32 |
Correct |
2 ms |
10868 KB |
Output is correct |
33 |
Correct |
2 ms |
10840 KB |
Output is correct |
34 |
Correct |
2 ms |
10840 KB |
Output is correct |
35 |
Correct |
2 ms |
10844 KB |
Output is correct |
36 |
Correct |
2 ms |
10844 KB |
Output is correct |
37 |
Correct |
3 ms |
10844 KB |
Output is correct |
38 |
Correct |
2 ms |
10844 KB |
Output is correct |
39 |
Correct |
3 ms |
10904 KB |
Output is correct |
40 |
Correct |
2 ms |
10844 KB |
Output is correct |
41 |
Correct |
3 ms |
10840 KB |
Output is correct |
42 |
Correct |
2 ms |
10840 KB |
Output is correct |
43 |
Correct |
2 ms |
10844 KB |
Output is correct |
44 |
Correct |
2 ms |
10844 KB |
Output is correct |
45 |
Correct |
2 ms |
10840 KB |
Output is correct |
46 |
Correct |
3 ms |
10844 KB |
Output is correct |
47 |
Correct |
3 ms |
10856 KB |
Output is correct |
48 |
Correct |
3 ms |
10844 KB |
Output is correct |
49 |
Correct |
2 ms |
10844 KB |
Output is correct |
50 |
Correct |
2 ms |
10844 KB |
Output is correct |
51 |
Correct |
2 ms |
10840 KB |
Output is correct |
52 |
Correct |
2 ms |
10844 KB |
Output is correct |
53 |
Correct |
2 ms |
10844 KB |
Output is correct |
54 |
Correct |
2 ms |
11096 KB |
Output is correct |
55 |
Correct |
2 ms |
10840 KB |
Output is correct |
56 |
Correct |
2 ms |
10864 KB |
Output is correct |
57 |
Correct |
2 ms |
10844 KB |
Output is correct |
58 |
Correct |
2 ms |
10844 KB |
Output is correct |
59 |
Correct |
3 ms |
11100 KB |
Output is correct |
60 |
Correct |
2 ms |
10844 KB |
Output is correct |
61 |
Correct |
2 ms |
10844 KB |
Output is correct |
62 |
Correct |
2 ms |
10844 KB |
Output is correct |
63 |
Correct |
2 ms |
10840 KB |
Output is correct |
64 |
Correct |
3 ms |
10844 KB |
Output is correct |
65 |
Correct |
2 ms |
10844 KB |
Output is correct |
66 |
Correct |
82 ms |
54896 KB |
Output is correct |
67 |
Correct |
83 ms |
54980 KB |
Output is correct |
68 |
Correct |
106 ms |
50628 KB |
Output is correct |
69 |
Correct |
92 ms |
53216 KB |
Output is correct |
70 |
Correct |
93 ms |
45752 KB |
Output is correct |
71 |
Correct |
118 ms |
48504 KB |
Output is correct |
72 |
Correct |
123 ms |
45796 KB |
Output is correct |
73 |
Correct |
124 ms |
47896 KB |
Output is correct |
74 |
Correct |
102 ms |
43192 KB |
Output is correct |
75 |
Correct |
102 ms |
44224 KB |
Output is correct |
76 |
Correct |
78 ms |
38084 KB |
Output is correct |
77 |
Correct |
74 ms |
37560 KB |
Output is correct |
78 |
Correct |
72 ms |
37048 KB |
Output is correct |
79 |
Correct |
67 ms |
36544 KB |
Output is correct |
80 |
Correct |
51 ms |
34012 KB |
Output is correct |
81 |
Correct |
74 ms |
33596 KB |
Output is correct |
82 |
Correct |
9 ms |
17108 KB |
Output is correct |
83 |
Correct |
12 ms |
17032 KB |
Output is correct |
84 |
Correct |
13 ms |
17360 KB |
Output is correct |
85 |
Correct |
8 ms |
17108 KB |
Output is correct |
86 |
Correct |
7 ms |
17108 KB |
Output is correct |
87 |
Correct |
8 ms |
16992 KB |
Output is correct |
88 |
Correct |
3 ms |
11100 KB |
Output is correct |
89 |
Correct |
3 ms |
11100 KB |
Output is correct |
90 |
Correct |
4 ms |
11024 KB |
Output is correct |
91 |
Correct |
3 ms |
11352 KB |
Output is correct |
92 |
Correct |
3 ms |
11096 KB |
Output is correct |
93 |
Correct |
3 ms |
11100 KB |
Output is correct |
94 |
Correct |
3 ms |
11100 KB |
Output is correct |
95 |
Correct |
3 ms |
11096 KB |
Output is correct |
96 |
Correct |
4 ms |
11096 KB |
Output is correct |
97 |
Correct |
4 ms |
11096 KB |
Output is correct |
98 |
Correct |
3 ms |
11100 KB |
Output is correct |
99 |
Correct |
4 ms |
11128 KB |
Output is correct |
100 |
Correct |
3 ms |
11096 KB |
Output is correct |
101 |
Correct |
3 ms |
11100 KB |
Output is correct |
102 |
Correct |
3 ms |
11160 KB |
Output is correct |
103 |
Correct |
4 ms |
10868 KB |
Output is correct |
104 |
Correct |
4 ms |
11136 KB |
Output is correct |
105 |
Correct |
3 ms |
11100 KB |
Output is correct |
106 |
Correct |
4 ms |
11100 KB |
Output is correct |
107 |
Correct |
3 ms |
11100 KB |
Output is correct |
108 |
Correct |
181 ms |
45668 KB |
Output is correct |
109 |
Correct |
135 ms |
44972 KB |
Output is correct |
110 |
Correct |
130 ms |
45084 KB |
Output is correct |
111 |
Correct |
158 ms |
44992 KB |
Output is correct |
112 |
Correct |
157 ms |
45588 KB |
Output is correct |
113 |
Correct |
185 ms |
58356 KB |
Output is correct |
114 |
Correct |
177 ms |
54028 KB |
Output is correct |
115 |
Correct |
168 ms |
51268 KB |
Output is correct |
116 |
Correct |
184 ms |
49084 KB |
Output is correct |
117 |
Correct |
150 ms |
45488 KB |
Output is correct |
118 |
Correct |
184 ms |
46596 KB |
Output is correct |
119 |
Correct |
164 ms |
46384 KB |
Output is correct |
120 |
Correct |
179 ms |
46196 KB |
Output is correct |
121 |
Correct |
108 ms |
44708 KB |
Output is correct |
122 |
Correct |
104 ms |
42036 KB |
Output is correct |
123 |
Correct |
57 ms |
34732 KB |
Output is correct |
124 |
Correct |
109 ms |
46980 KB |
Output is correct |
125 |
Correct |
98 ms |
47288 KB |
Output is correct |
126 |
Correct |
103 ms |
47280 KB |
Output is correct |
127 |
Correct |
102 ms |
47172 KB |
Output is correct |
128 |
Correct |
3 ms |
11096 KB |
Output is correct |
129 |
Correct |
3 ms |
11100 KB |
Output is correct |
130 |
Correct |
4 ms |
11096 KB |
Output is correct |
131 |
Correct |
4 ms |
11100 KB |
Output is correct |
132 |
Correct |
3 ms |
11096 KB |
Output is correct |
133 |
Correct |
3 ms |
11100 KB |
Output is correct |
134 |
Correct |
3 ms |
11096 KB |
Output is correct |
135 |
Correct |
3 ms |
11100 KB |
Output is correct |
136 |
Correct |
3 ms |
11096 KB |
Output is correct |
137 |
Correct |
2 ms |
11100 KB |
Output is correct |
138 |
Correct |
2 ms |
11100 KB |
Output is correct |
139 |
Correct |
3 ms |
11100 KB |
Output is correct |
140 |
Correct |
3 ms |
11100 KB |
Output is correct |
141 |
Correct |
3 ms |
11100 KB |
Output is correct |
142 |
Correct |
3 ms |
11100 KB |
Output is correct |
143 |
Correct |
3 ms |
11100 KB |
Output is correct |
144 |
Correct |
3 ms |
11096 KB |
Output is correct |
145 |
Correct |
3 ms |
11100 KB |
Output is correct |
146 |
Correct |
3 ms |
11096 KB |
Output is correct |
147 |
Correct |
3 ms |
11352 KB |
Output is correct |
148 |
Correct |
4 ms |
11204 KB |
Output is correct |
149 |
Correct |
3 ms |
11100 KB |
Output is correct |
150 |
Correct |
3 ms |
11096 KB |
Output is correct |
151 |
Correct |
3 ms |
11100 KB |
Output is correct |
152 |
Correct |
2 ms |
10844 KB |
Output is correct |
153 |
Correct |
3 ms |
10968 KB |
Output is correct |
154 |
Correct |
2 ms |
10840 KB |
Output is correct |
155 |
Correct |
141 ms |
45288 KB |
Output is correct |
156 |
Correct |
126 ms |
44724 KB |
Output is correct |
157 |
Correct |
119 ms |
43196 KB |
Output is correct |
158 |
Correct |
114 ms |
39296 KB |
Output is correct |
159 |
Correct |
93 ms |
36036 KB |
Output is correct |
160 |
Correct |
90 ms |
33216 KB |
Output is correct |
161 |
Correct |
85 ms |
32648 KB |
Output is correct |
162 |
Correct |
74 ms |
31676 KB |
Output is correct |
163 |
Correct |
71 ms |
31396 KB |
Output is correct |
164 |
Correct |
88 ms |
31184 KB |
Output is correct |
165 |
Correct |
74 ms |
30660 KB |
Output is correct |
166 |
Correct |
75 ms |
30656 KB |
Output is correct |
167 |
Correct |
81 ms |
30892 KB |
Output is correct |
168 |
Correct |
76 ms |
36492 KB |
Output is correct |
169 |
Correct |
167 ms |
53336 KB |
Output is correct |
170 |
Correct |
178 ms |
49852 KB |
Output is correct |
171 |
Correct |
163 ms |
50936 KB |
Output is correct |
172 |
Correct |
161 ms |
48156 KB |
Output is correct |
173 |
Correct |
107 ms |
39216 KB |
Output is correct |
174 |
Correct |
106 ms |
40896 KB |
Output is correct |
175 |
Correct |
116 ms |
40796 KB |
Output is correct |
176 |
Correct |
92 ms |
38852 KB |
Output is correct |
177 |
Correct |
82 ms |
37060 KB |
Output is correct |
178 |
Correct |
119 ms |
44768 KB |
Output is correct |
179 |
Correct |
141 ms |
45492 KB |
Output is correct |
180 |
Correct |
119 ms |
42940 KB |
Output is correct |
181 |
Correct |
123 ms |
43960 KB |
Output is correct |
182 |
Correct |
2 ms |
10844 KB |
Output is correct |
183 |
Correct |
3 ms |
11100 KB |
Output is correct |
184 |
Correct |
3 ms |
11100 KB |
Output is correct |
185 |
Correct |
3 ms |
11100 KB |
Output is correct |
186 |
Correct |
3 ms |
11100 KB |
Output is correct |
187 |
Correct |
3 ms |
11096 KB |
Output is correct |
188 |
Correct |
3 ms |
11096 KB |
Output is correct |
189 |
Correct |
3 ms |
11100 KB |
Output is correct |
190 |
Correct |
4 ms |
11100 KB |
Output is correct |
191 |
Correct |
3 ms |
11108 KB |
Output is correct |
192 |
Correct |
2 ms |
10864 KB |
Output is correct |
193 |
Correct |
3 ms |
11100 KB |
Output is correct |
194 |
Correct |
4 ms |
11096 KB |
Output is correct |
195 |
Correct |
3 ms |
11100 KB |
Output is correct |
196 |
Correct |
3 ms |
10928 KB |
Output is correct |
197 |
Correct |
2 ms |
11100 KB |
Output is correct |
198 |
Correct |
3 ms |
11100 KB |
Output is correct |
199 |
Correct |
3 ms |
11132 KB |
Output is correct |
200 |
Correct |
3 ms |
11096 KB |
Output is correct |
201 |
Correct |
3 ms |
11100 KB |
Output is correct |
202 |
Correct |
3 ms |
11100 KB |
Output is correct |
203 |
Correct |
3 ms |
11100 KB |
Output is correct |
204 |
Correct |
3 ms |
11096 KB |
Output is correct |
205 |
Correct |
3 ms |
11100 KB |
Output is correct |
206 |
Correct |
3 ms |
11100 KB |
Output is correct |
207 |
Correct |
3 ms |
11100 KB |
Output is correct |
208 |
Correct |
3 ms |
11352 KB |
Output is correct |
209 |
Correct |
7 ms |
17108 KB |
Output is correct |
210 |
Correct |
55 ms |
33472 KB |
Output is correct |
211 |
Correct |
91 ms |
42860 KB |
Output is correct |
212 |
Correct |
109 ms |
48504 KB |
Output is correct |
213 |
Correct |
116 ms |
51640 KB |
Output is correct |
214 |
Correct |
59 ms |
37328 KB |
Output is correct |
215 |
Correct |
58 ms |
34900 KB |
Output is correct |
216 |
Correct |
137 ms |
43924 KB |
Output is correct |
217 |
Correct |
136 ms |
38568 KB |
Output is correct |
218 |
Correct |
84 ms |
33140 KB |
Output is correct |
219 |
Correct |
67 ms |
32204 KB |
Output is correct |
220 |
Correct |
87 ms |
31836 KB |
Output is correct |
221 |
Correct |
64 ms |
31768 KB |
Output is correct |
222 |
Correct |
70 ms |
34756 KB |
Output is correct |
223 |
Correct |
116 ms |
45236 KB |
Output is correct |
224 |
Correct |
145 ms |
43044 KB |
Output is correct |
225 |
Correct |
125 ms |
37724 KB |
Output is correct |
226 |
Correct |
97 ms |
38820 KB |
Output is correct |
227 |
Correct |
127 ms |
38388 KB |
Output is correct |
228 |
Correct |
91 ms |
34912 KB |
Output is correct |
229 |
Correct |
76 ms |
34000 KB |
Output is correct |
230 |
Correct |
135 ms |
40376 KB |
Output is correct |
231 |
Correct |
112 ms |
39580 KB |
Output is correct |