// verification-helper: PROBLEM https://judge.yosupo.jp/problem/bipartitematching static void Solve(ConsoleReader cr, Utf8ConsoleWriter cw) { int l = cr; int r = cr; int m = cr; var mf = new MfGraphInt(l + r + 2); for (int i = 0; i < m; i++) { int a = cr; int b = cr; mf.AddEdge(a, l + b, 1); } for (int i = 0; i < l; i++) { mf.AddEdge(l + r, i, 1); } for (int i = 0; i < r; i++) { mf.AddEdge(l + i, l + r + 1, 1); } cw.WriteLine(mf.Flow(l + r, l + r + 1)); foreach (var e in mf.Edges()) { int ll = e.From; int rr = e.To; if (e.Flow == 1 && ll < l && rr < l + r) { cw.WriteLineJoin(e.From, e.To - l); } } }
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/convolution_mod static void Solve(ConsoleReader cr, Utf8ConsoleWriter cw) { int n = cr; int m = cr; int[] a = cr.Repeat(n); int[] b = cr.Repeat(m); cw.WriteLineJoin(MathLib.Convolution <Mod998244353>(a, b)); }
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/two_sat static void Solve(ConsoleReader cr, Utf8ConsoleWriter cw) { _ = cr.Ascii(); _ = cr.Ascii(); int n = cr; int m = cr; var twoSat = new TwoSat(n); for (int i = 0; i < m; i++) { int a = cr; int b = cr; _ = cr.Int(); int a1 = Math.Abs(a) - 1; bool a2 = a >= 0; int b1 = Math.Abs(b) - 1; bool b2 = b >= 0; twoSat.AddClause(a1, a2, b1, b2); } if (twoSat.Satisfiable()) { cw.WriteLine("s SATISFIABLE"); cw.Write("v "); var res = new int[n + 1]; var answer = twoSat.Answer(); for (int i = 0; i < n; i++) { if (answer[i]) { res[i] = i + 1; } else { res[i] = -(i + 1); } } cw.WriteLineJoin(res); } else { cw.WriteLine("s UNSATISFIABLE"); } }
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/scc static void Solve(ConsoleReader cr, Utf8ConsoleWriter cw) { int n = cr; int m = cr; var g = new SccGraph(n); for (int i = 0; i < m; i++) { int u = cr; int v = cr; g.AddEdge(u, v); } var scc = g.SCC(); cw.WriteLine(scc.Length); foreach (var v in scc) { cw.Write(v.Length); cw.Write(' '); cw.WriteLineJoin(v); } }
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/zalgorithm static void Solve(ConsoleReader cr, Utf8ConsoleWriter cw) { string s = cr; cw.WriteLineJoin(StringLib.ZAlgorithm(s)); }
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/suffixarray static void Solve(ConsoleReader cr, Utf8ConsoleWriter cw) { string s = cr; cw.WriteLineJoin(StringLib.SuffixArray(s)); }