1- #define PROBLEM " https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A"
1+ #define PROBLEM \
2+ " https://onlinejudge.u-aizu.ac.jp/problems/ITP1_1_A"
23#include " ../template.hpp"
34#include " ../../../library/contest/random.hpp"
45#include " ../../../library/graphs/functional_graph_processor.hpp"
@@ -8,7 +9,7 @@ struct functional_graph_processor {
89 init (sz (next));
910 build (next);
1011 }
11- template <class Graph_t >
12+ template <class Graph_t >
1213 functional_graph_processor (const Graph_t &g) {
1314 init (g.n );
1415 build (g);
@@ -100,31 +101,30 @@ struct functional_graph_processor {
100101 }
101102 int n;
102103 vector<vector<int >> cycle;
103- vector<int > cycle_id; // id of the cycle it belongs to,
104- // -1 if not part of one
105- vector<int > cycle_pos; // position in its cycle, -1 if
106- // not part of one
107- vector<int > cycle_prev; // previous vertex in its cycle,
108- // -1 if not part of one
109- vector<int > component_size; // size of its weakly
110- // connected component
111- vector<int > root_of; // first reachable node in a cycle
112- vector<int > depth; // distance to its root
113- vector<vector<int >> abr; // forest of arborescences of reversed edges not
114- // on the cycles
115- vector<int > order; // dfs order of abr
116- vector<int > pos; // pos in the dfs order
117- vector<int > end; // [pos[u], end[u]) denotes the subtree
118- vector<int > size; // size of the subtree in abr
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
114+ 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
119121};
120-
121122bool equal (const basic_string<int > &a, const vi &b) {
122123 if (sz (a) != sz (b)) return 0 ;
123124 for (int i = 0 ; i < sz (a); i++)
124125 if (a[i] != b[i]) return 0 ;
125126 return 1 ;
126127}
127-
128128int main () {
129129 cin.tie (0 )->sync_with_stdio (0 );
130130 for (int num_tests = 100 ; num_tests--;) {
@@ -135,19 +135,23 @@ int main() {
135135 functional_graph_processor fgp (a);
136136 assert (cycle == fgp.cycle );
137137 for (int i = 0 ; i < n; i++) {
138- int root = cycle[t[i].root_of .first ][t[i].root_of .second ];
138+ int root =
139+ cycle[t[i].root_of .first ][t[i].root_of .second ];
139140 assert (root == fgp.root_of [i]);
140141 assert (equal (t[i].childs , fgp.abr [i]));
141142 assert ((root == i) == (fgp.cycle_id [i] != -1 ));
142143 if (root == i) {
143144 assert (t[i].root_of .first == fgp.cycle_id [i]);
144145 assert (t[i].root_of .second == fgp.cycle_pos [i]);
145146 int cyc_len = ssize (cycle[t[i].root_of .first ]);
146- assert (cycle[t[i].root_of .first ][(t[i].root_of .second + 1 ) % cyc_len] ==
147- a[i]);
147+ assert (
148+ cycle[t[i].root_of .first ]
149+ [(t[i].root_of .second + 1 ) % cyc_len] ==
150+ a[i]);
148151 assert (fgp.cycle_prev [i] ==
149- cycle[t[i].root_of .first ]
150- [(t[i].root_of .second - 1 + cyc_len) % cyc_len]);
152+ cycle[t[i].root_of .first ]
153+ [(t[i].root_of .second - 1 + cyc_len) %
154+ cyc_len]);
151155 } else {
152156 assert (fgp.cycle_prev [i] == -1 );
153157 }
0 commit comments