MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / main

Method main

src/class189/Code01_SCC1.java:158–190  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

156 }
157
158 public static void main(String[] args) throws Exception {
159 FastReader in = new FastReader(System.in);
160 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
161 n = in.nextInt();
162 m = in.nextInt();
163 for (int i = 1, u, v; i <= m; i++) {
164 u = in.nextInt();
165 v = in.nextInt();
166 addEdge(u, v);
167 }
168 for (int i = 1; i <= n; i++) {
169 if (dfn[i] == 0) {
170 // tarjan1(i);
171 tarjan2(i);
172 }
173 }
174 out.println(sccCnt);
175 for (int i = 1; i <= sccCnt; i++) {
176 Arrays.sort(sccArr, sccl[i], sccr[i] + 1);
177 }
178 for (int i = 1; i <= n; i++) {
179 int scc = belong[i];
180 if (!sccPrint[scc]) {
181 sccPrint[scc] = true;
182 for (int j = sccl[scc]; j <= sccr[scc]; j++) {
183 out.print(sccArr[j] + " ");
184 }
185 out.println();
186 }
187 }
188 out.flush();
189 out.close();
190 }
191
192 // 读写工具类
193 static class FastReader {

Callers

nothing calls this directly

Calls 8

nextIntMethod · 0.95
addEdgeMethod · 0.95
tarjan2Method · 0.95
printlnMethod · 0.45
sortMethod · 0.45
printMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected