@@ -131,26 +131,31 @@ int main() {
131131 int n = rnd (1 , 1000 );
132132 vector<int > a (n);
133133 for (int i = 0 ; i < n; i++) a[i] = rnd (0 , n - 1 );
134- auto [t , cycle] = func_graph (a);
134+ auto [root_of , cycle, childs ] = func_graph (a);
135135 functional_graph_processor fgp (a);
136- assert (cycle == fgp.cycle );
136+ assert (sz (cycle) == sz (fgp.cycle ));
137+ for (int i = 0 ; i < sz (cycle); i++) {
138+ assert (sz (cycle[i]) == sz (fgp.cycle [i]));
139+ for (int j = 0 ; j < sz (cycle[i]); j++)
140+ assert (cycle[i][j] == fgp.cycle [i][j]);
141+ }
137142 for (int i = 0 ; i < n; i++) {
138143 int root =
139- cycle[t [i].root_of . first ][t [i]. root_of .second ];
144+ cycle[root_of [i].first ][root_of [i].second ];
140145 assert (root == fgp.root_of [i]);
141- assert (equal (t [i]. childs , fgp.abr [i]));
146+ assert (equal (childs [i], fgp.abr [i]));
142147 assert ((root == i) == (fgp.cycle_id [i] != -1 ));
143148 if (root == i) {
144- assert (t [i]. root_of .first == fgp.cycle_id [i]);
145- assert (t [i]. root_of .second == fgp.cycle_pos [i]);
146- int cyc_len = ssize (cycle[t [i]. root_of .first ]);
149+ assert (root_of [i].first == fgp.cycle_id [i]);
150+ assert (root_of [i].second == fgp.cycle_pos [i]);
151+ int cyc_len = ssize (cycle[root_of [i].first ]);
147152 assert (
148- cycle[t [i]. root_of .first ]
149- [(t [i]. root_of .second + 1 ) % cyc_len] ==
153+ cycle[root_of [i].first ]
154+ [(root_of [i].second + 1 ) % cyc_len] ==
150155 a[i]);
151156 assert (fgp.cycle_prev [i] ==
152- cycle[t [i]. root_of .first ]
153- [(t [i]. root_of .second - 1 + cyc_len) %
157+ cycle[root_of [i].first ]
158+ [(root_of [i].second - 1 + cyc_len) %
154159 cyc_len]);
155160 } else {
156161 assert (fgp.cycle_prev [i] == -1 );
0 commit comments