@@ -9,7 +9,7 @@ struct functional_graph_processor {
99 init (sz (next));
1010 build (next);
1111 }
12- template <class Graph_t >
12+ template <class Graph_t >
1313 functional_graph_processor (const Graph_t &g) {
1414 init (g.n );
1515 build (g);
@@ -101,36 +101,36 @@ struct functional_graph_processor {
101101 }
102102 int n;
103103 vector<vector<int >> cycle;
104- vector<int > cycle_id; // id of the cycle it belongs to,
105- // -1 if not part of one
106- vector<int > cycle_pos; // position in its cycle, -1 if
107- // not part of one
108- vector<int > cycle_prev; // previous vertex in its cycle,
109- // -1 if not part of one
110- vector<int > component_size; // size of its weakly
111- // connected component
112- vector<int > root_of; // first reachable node in a cycle
113- vector<int > depth; // distance to its root
104+ vector<int > cycle_id; // id of the cycle it belongs to,
105+ // -1 if not part of one
106+ vector<int > cycle_pos; // position in its cycle, -1 if
107+ // not part of one
108+ vector<int > cycle_prev; // previous vertex in its cycle,
109+ // -1 if not part of one
110+ vector<int > component_size; // size of its weakly
111+ // connected component
112+ vector<int > root_of; // first reachable node in a cycle
113+ vector<int > depth; // distance to its root
114114 vector<vector<int >>
115- abr; // forest of arborescences of reversed edges not
116- // on the cycles
117- vector<int > order; // dfs order of abr
118- vector<int > pos; // pos in the dfs order
119- vector<int > end; // [pos[u], end[u]) denotes the subtree
120- vector<int > size; // size of the subtree in abr
115+ abr; // forest of arborescences of reversed edges not
116+ // on the cycles
117+ vector<int > order; // dfs order of abr
118+ vector<int > pos; // pos in the dfs order
119+ vector<int > end; // [pos[u], end[u]) denotes the subtree
120+ vector<int > size; // size of the subtree in abr
121121};
122122int main () {
123123 cin.tie (0 )->sync_with_stdio (0 );
124- for (int num_tests = 1000 ; num_tests--;) {
125- int n = rnd (1 , 10000 );
124+ for (int num_tests = 100 ; num_tests--;) {
125+ int n = rnd (1 , 1000 );
126126 vector<int > a (n);
127127 for (int i = 0 ; i < n; i++) a[i] = rnd (0 , n - 1 );
128128 auto [t, cycle] = func_graph (a);
129129 functional_graph_processor fgp (a);
130130 assert (cycle == fgp.cycle );
131131 for (int i = 0 ; i < n; i++) {
132132 int root =
133- cycle[t[i].root_of .first ][t[i].root_of .second ];
133+ cycle[t[i].root_of .first ][t[i].root_of .second ];
134134 assert (root == fgp.root_of [i]);
135135 assert (t[i].childs == fgp.abr [i]);
136136 assert ((root == i) == (fgp.cycle_id [i] != -1 ));
@@ -139,13 +139,13 @@ int main() {
139139 assert (t[i].root_of .second == fgp.cycle_pos [i]);
140140 int cyc_len = ssize (cycle[t[i].root_of .first ]);
141141 assert (
142- cycle[t[i].root_of .first ]
143- [(t[i].root_of .second + 1 ) % cyc_len] ==
144- a[i]);
142+ cycle[t[i].root_of .first ]
143+ [(t[i].root_of .second + 1 ) % cyc_len] ==
144+ a[i]);
145145 assert (fgp.cycle_prev [i] ==
146- cycle[t[i].root_of .first ]
147- [(t[i].root_of .second - 1 + cyc_len) %
148- cyc_len]);
146+ cycle[t[i].root_of .first ]
147+ [(t[i].root_of .second - 1 + cyc_len) %
148+ cyc_len]);
149149 } else {
150150 assert (fgp.cycle_prev [i] == -1 );
151151 }
0 commit comments