diff --git a/SELF_CONTAINED_HEADER_MIGRATION.md b/SELF_CONTAINED_HEADER_MIGRATION.md index 35ccc951..7715b4e7 100644 --- a/SELF_CONTAINED_HEADER_MIGRATION.md +++ b/SELF_CONTAINED_HEADER_MIGRATION.md @@ -27,7 +27,7 @@ import と別名を意図的に提供する集約ヘッダーのため、自己 | ----------------------------------------- | -------- | ---- | | リポジトリ内の `.hpp` | 調査済み | 320 | | 自己完結化して継続検査しているヘッダー | 移行済み | 319 | -| `template/template.hpp` に依存する verify | 移行待ち | 243 | +| `template/template.hpp` に依存する verify | 移行待ち | 150 | 移行済みヘッダーの正本は [`scripts/self-contained-headers.txt`](scripts/self-contained-headers.txt)、 @@ -55,11 +55,12 @@ import と別名を意図的に提供する集約ヘッダーのため、自己 ### 3. 対応する verify を移行する -状態: 未着手 +状態: 進行中 依存先ヘッダーが自己完結した後、対応する verify から `template/template.hpp` を削除する。必要な標準ヘッダー、型別名、入出力処理、 -補助関数は verify 側に明示する。移行後は +補助関数は verify 側に明示する。verify では簡潔さのため +`using namespace std;` の使用を許可する。移行後は `scripts/verify-template-include-allowlist.txt` から対象を削除する。 ### 4. 移行済みコードの逆戻りを防ぐ @@ -143,6 +144,21 @@ g++ -std=c++17 -fsyntax-only -x c++ -include ./path/to/header.hpp /dev/null | 2026-08-10 | `geometry/template.hpp`、`graph/flow/` の10ヘッダー、`graph/mst/` の1ヘッダー、`graph/others/` の2ヘッダー | 標準 include と `std::` 修飾 | | 2026-08-10 | `structure/bbst/` の10ヘッダー、`structure/dynamic-tree/` の13ヘッダー、`structure/wavelet/` の2ヘッダー | 標準 include と `std::` 修飾 | | 2026-08-10 | 移行済みヘッダー34件 | 未修飾標準名と include guard を修正 | +| 2026-08-10 | AOJ DPL の verify 7件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ DPL の組合せ verify 3件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ DSL の verify 6件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ GRL の最短路 verify 6件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ GRL の全域木 verify 5件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ GRL の連結性 verify 3件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ GRL の木 verify 6件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ GRL のフロー verify 6件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ の基礎数論 verify 5件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ ALDS の verify 6件 | テンプレート依存を削除 | +| 2026-08-10 | AOJ CGL の verify 16件 | 出力精度を維持して依存を削除 | +| 2026-08-10 | Library Checker Static RMQ の verify 6件 | テンプレート依存を削除 | +| 2026-08-10 | Library Checker LCA の verify 4件 | テンプレート依存を削除 | +| 2026-08-10 | Library Checker Range Kth Smallest の verify 3件 | テンプレート依存を削除 | +| 2026-08-10 | Library Checker の基礎 verify 11件 | テンプレート依存を削除 | ## 次の候補 diff --git a/scripts/verify-template-include-allowlist.txt b/scripts/verify-template-include-allowlist.txt index 08cd59f4..fe6c5a02 100644 --- a/scripts/verify-template-include-allowlist.txt +++ b/scripts/verify-template-include-allowlist.txt @@ -33,75 +33,6 @@ test/verify/aoj-2821.test.cpp test/verify/aoj-3022.test.cpp test/verify/aoj-3139.test.cpp test/verify/aoj-3198.test.cpp -test/verify/aoj-alds-1-1-c-2.test.cpp -test/verify/aoj-alds-1-1-c.test.cpp -test/verify/aoj-alds-1-11-c.test.cpp -test/verify/aoj-alds-1-14-b.test.cpp -test/verify/aoj-alds-1-14-d.test.cpp -test/verify/aoj-alds-1-9-c.test.cpp -test/verify/aoj-cgl-1-a.test.cpp -test/verify/aoj-cgl-1-b.test.cpp -test/verify/aoj-cgl-1-c.test.cpp -test/verify/aoj-cgl-2-a.test.cpp -test/verify/aoj-cgl-2-b.test.cpp -test/verify/aoj-cgl-2-c.test.cpp -test/verify/aoj-cgl-2-d.test.cpp -test/verify/aoj-cgl-3-a.test.cpp -test/verify/aoj-cgl-3-b.test.cpp -test/verify/aoj-cgl-3-c.test.cpp -test/verify/aoj-cgl-4-a.test.cpp -test/verify/aoj-cgl-4-b.test.cpp -test/verify/aoj-cgl-4-c.test.cpp -test/verify/aoj-cgl-7-d.test.cpp -test/verify/aoj-cgl-7-e.test.cpp -test/verify/aoj-cgl-7-h.test.cpp -test/verify/aoj-dpl-1-b.test.cpp -test/verify/aoj-dpl-1-c.test.cpp -test/verify/aoj-dpl-1-d.test.cpp -test/verify/aoj-dpl-1-e.test.cpp -test/verify/aoj-dpl-1-f.test.cpp -test/verify/aoj-dpl-1-i.test.cpp -test/verify/aoj-dpl-3-c.test.cpp -test/verify/aoj-dpl-5-g.test.cpp -test/verify/aoj-dpl-5-i.test.cpp -test/verify/aoj-dpl-5-j.test.cpp -test/verify/aoj-dsl-1-a.test.cpp -test/verify/aoj-dsl-1-b.test.cpp -test/verify/aoj-dsl-2-a.test.cpp -test/verify/aoj-dsl-2-b-2.test.cpp -test/verify/aoj-dsl-2-b.test.cpp -test/verify/aoj-dsl-2-d.test.cpp -test/verify/aoj-grl-1-a-2.test.cpp -test/verify/aoj-grl-1-a-3.test.cpp -test/verify/aoj-grl-1-a.test.cpp -test/verify/aoj-grl-1-b-2.test.cpp -test/verify/aoj-grl-1-b.test.cpp -test/verify/aoj-grl-1-c.test.cpp -test/verify/aoj-grl-2-a-2.test.cpp -test/verify/aoj-grl-2-a-3.test.cpp -test/verify/aoj-grl-2-a-4.test.cpp -test/verify/aoj-grl-2-a.test.cpp -test/verify/aoj-grl-2-b.test.cpp -test/verify/aoj-grl-3-a.test.cpp -test/verify/aoj-grl-3-b.test.cpp -test/verify/aoj-grl-3-c.test.cpp -test/verify/aoj-grl-5-a-3.test.cpp -test/verify/aoj-grl-5-a.test.cpp -test/verify/aoj-grl-5-c-2.test.cpp -test/verify/aoj-grl-5-c-3.test.cpp -test/verify/aoj-grl-5-c-4.test.cpp -test/verify/aoj-grl-5-c.test.cpp -test/verify/aoj-grl-6-a-2.test.cpp -test/verify/aoj-grl-6-a-3.test.cpp -test/verify/aoj-grl-6-a-4.test.cpp -test/verify/aoj-grl-6-a.test.cpp -test/verify/aoj-grl-6-b.test.cpp -test/verify/aoj-grl-7-a.test.cpp -test/verify/aoj-itp1-3-d.test.cpp -test/verify/aoj-ntl-1-a.test.cpp -test/verify/aoj-ntl-1-b.test.cpp -test/verify/aoj-ntl-1-d.test.cpp -test/verify/aoj-ntl-1-e.test.cpp test/verify/yosupo-area-of-union-of-rectangles.test.cpp test/verify/yosupo-assignment.test.cpp test/verify/yosupo-bernoulli-number.test.cpp @@ -111,7 +42,6 @@ test/verify/yosupo-bitwise-and-convolution-2.test.cpp test/verify/yosupo-bitwise-and-convolution-3.test.cpp test/verify/yosupo-bitwise-and-convolution.test.cpp test/verify/yosupo-bitwise-xor-convolution.test.cpp -test/verify/yosupo-cartesian-tree.test.cpp test/verify/yosupo-chromatic-number.test.cpp test/verify/yosupo-composition-of-formal-power-series-large.test.cpp test/verify/yosupo-compositional-inverse-of-formal-power-series-large.test.cpp @@ -131,11 +61,9 @@ test/verify/yosupo-dynamic-tree-vertex-add-subtree-sum-3.test.cpp test/verify/yosupo-dynamic-tree-vertex-set-path-composite-4.test.cpp test/verify/yosupo-eertree.test.cpp test/verify/yosupo-enumerate-palindromes.test.cpp -test/verify/yosupo-enumerate-primes.test.cpp test/verify/yosupo-enumerate-quotients.test.cpp test/verify/yosupo-enumerate-triangles.test.cpp test/verify/yosupo-exp-of-formal-power-series.test.cpp -test/verify/yosupo-factorize.test.cpp test/verify/yosupo-find-linear-recurrence.test.cpp test/verify/yosupo-frequency-table-of-tree-distance.test.cpp test/verify/yosupo-general-matching.test.cpp @@ -144,10 +72,6 @@ test/verify/yosupo-inv-of-formal-power-series.test.cpp test/verify/yosupo-k-shortest-walk.test.cpp test/verify/yosupo-kth-root-integer.test.cpp test/verify/yosupo-kth-term-of-linearly-recurrent-sequence.test.cpp -test/verify/yosupo-lca-2.test.cpp -test/verify/yosupo-lca-3.test.cpp -test/verify/yosupo-lca-4.test.cpp -test/verify/yosupo-lca.test.cpp test/verify/yosupo-line-add-get-min-2.test.cpp test/verify/yosupo-line-add-get-min.test.cpp test/verify/yosupo-log-of-formal-power-series.test.cpp @@ -161,7 +85,6 @@ test/verify/yosupo-multipoint-evaluation.test.cpp test/verify/yosupo-number-of-increasing-sequences-between-two-sequences.test.cpp test/verify/yosupo-number-of-substrings.test.cpp test/verify/yosupo-partition-function.test.cpp -test/verify/yosupo-persistent-unionfind.test.cpp test/verify/yosupo-point-add-rectangle-sum-2.test.cpp test/verify/yosupo-point-add-rectangle-sum-3.test.cpp test/verify/yosupo-point-add-rectangle-sum-4.test.cpp @@ -174,23 +97,17 @@ test/verify/yosupo-point-set-tree-path-composite-sum.test.cpp test/verify/yosupo-polynomial-interpolation.test.cpp test/verify/yosupo-polynomial-taylor-shift.test.cpp test/verify/yosupo-pow-of-formal-power-series.test.cpp -test/verify/yosupo-primality-test.test.cpp test/verify/yosupo-queue-operate-all-composite.test.cpp test/verify/yosupo-range-affine-point-get.test.cpp test/verify/yosupo-range-affine-range-sum-2.test.cpp test/verify/yosupo-range-affine-range-sum-3.test.cpp test/verify/yosupo-range-affine-range-sum.test.cpp test/verify/yosupo-range-chmin-chmax-add-range-sum.test.cpp -test/verify/yosupo-range-kth-smallest-2.test.cpp -test/verify/yosupo-range-kth-smallest-3.test.cpp -test/verify/yosupo-range-kth-smallest.test.cpp test/verify/yosupo-range-linear-add-range-min.test.cpp test/verify/yosupo-rectangle-add-point-get.test.cpp test/verify/yosupo-rectangle-sum-2.test.cpp test/verify/yosupo-rectangle-sum.test.cpp -test/verify/yosupo-scc.test.cpp test/verify/yosupo-segment-add-get-min.test.cpp -test/verify/yosupo-set-xor-min.test.cpp test/verify/yosupo-sharp-p-subset-sum.test.cpp test/verify/yosupo-shift-of-sampling-points-of-polynomial.test.cpp test/verify/yosupo-shortest-path.test.cpp @@ -200,28 +117,18 @@ test/verify/yosupo-sqrt-of-formal-power-series.test.cpp test/verify/yosupo-static-range-count-distinct.test.cpp test/verify/yosupo-static-range-frequency.test.cpp test/verify/yosupo-static-range-inversions-query.test.cpp -test/verify/yosupo-static-range-sum.test.cpp test/verify/yosupo-static-rectangle-add-rectangle-sum.test.cpp -test/verify/yosupo-staticrmq-2.test.cpp -test/verify/yosupo-staticrmq-3.test.cpp -test/verify/yosupo-staticrmq-4.test.cpp -test/verify/yosupo-staticrmq-5.test.cpp -test/verify/yosupo-staticrmq-6.test.cpp -test/verify/yosupo-staticrmq.test.cpp test/verify/yosupo-stirling-number-of-the-first-kind.test.cpp test/verify/yosupo-stirling-number-of-the-second-kind.test.cpp test/verify/yosupo-subset-convolution.test.cpp -test/verify/yosupo-suffixarray.test.cpp test/verify/yosupo-sum-of-floor-of-linear.test.cpp test/verify/yosupo-tetration-mod.test.cpp test/verify/yosupo-three-edge-connected-components.test.cpp test/verify/yosupo-tree-decomposition-width-2.test.cpp -test/verify/yosupo-tree-diameter.test.cpp test/verify/yosupo-two-edge-connected-components-2.test.cpp test/verify/yosupo-two-edge-connected-components.test.cpp test/verify/yosupo-two-sat.test.cpp test/verify/yosupo-wildcard-pattern-matching.test.cpp -test/verify/yosupo-zalgorithm.test.cpp test/verify/yukicoder-1002.test.cpp test/verify/yukicoder-1069.test.cpp test/verify/yukicoder-1236.test.cpp diff --git a/test/verify/aoj-alds-1-1-c-2.test.cpp b/test/verify/aoj-alds-1-1-c-2.test.cpp index e5a368a3..9c01e295 100644 --- a/test/verify/aoj-alds-1-1-c-2.test.cpp +++ b/test/verify/aoj-alds-1-1-c-2.test.cpp @@ -1,15 +1,19 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/number-theory/prime-table.hpp" +using namespace std; + int main() { auto t = prime_table(100000000); int N; cin >> N; int ret = 0; - while(N--) { + while (N--) { int x; cin >> x; ret += t[x]; diff --git a/test/verify/aoj-alds-1-1-c.test.cpp b/test/verify/aoj-alds-1-1-c.test.cpp index 637bc68b..47f972b7 100644 --- a/test/verify/aoj-alds-1-1-c.test.cpp +++ b/test/verify/aoj-alds-1-1-c.test.cpp @@ -1,18 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_C +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/number-theory/is-prime.hpp" +using namespace std; + int main() { int N; cin >> N; int ret = 0; - while(N--) { + while (N--) { int x; cin >> x; ret += is_prime(x); } cout << ret << endl; } - diff --git a/test/verify/aoj-alds-1-11-c.test.cpp b/test/verify/aoj-alds-1-11-c.test.cpp index 935f826c..e67f62ec 100644 --- a/test/verify/aoj-alds-1-11-c.test.cpp +++ b/test/verify/aoj-alds-1-11-c.test.cpp @@ -1,19 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_11_C +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../graph/shortest-path/bfs.hpp" +using namespace std; int main() { int N; cin >> N; Graph<> g(N); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { int U, K; cin >> U >> K; --U; - for(int j = 0; j < K; j++) { + for (int j = 0; j < K; j++) { int x; cin >> x; --x; @@ -21,10 +25,11 @@ int main() { } } auto d = bfs(g, 0); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { cout << i + 1 << " "; - if(d[i] == numeric_limits< int >::max()) cout << -1 << "\n"; - else cout << d[i] << "\n"; + if (d[i] == numeric_limits::max()) + cout << -1 << "\n"; + else + cout << d[i] << "\n"; } } - diff --git a/test/verify/aoj-alds-1-14-b.test.cpp b/test/verify/aoj-alds-1-14-b.test.cpp index 1ce5a271..a5872573 100644 --- a/test/verify/aoj-alds-1-14-b.test.cpp +++ b/test/verify/aoj-alds-1-14-b.test.cpp @@ -1,16 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../string/rolling-hash.hpp" +using namespace std; + int main() { string T, P; cin >> T; cin >> P; RollingHash rh1(T), rh2(P); - for(int i = 0; i + P.size() <= T.size(); i++) { - if(rh1.get(i, i + P.size()) == rh2.get(0, P.size())) { + for (int i = 0; i + P.size() <= T.size(); i++) { + if (rh1.get(i, i + P.size()) == rh2.get(0, P.size())) { cout << i << endl; } } diff --git a/test/verify/aoj-alds-1-14-d.test.cpp b/test/verify/aoj-alds-1-14-d.test.cpp index 70125184..195f752f 100644 --- a/test/verify/aoj-alds-1-14-d.test.cpp +++ b/test/verify/aoj-alds-1-14-d.test.cpp @@ -1,9 +1,14 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_D +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../string/suffix-array.hpp" +using namespace std; + int main() { string S; int Q; @@ -11,7 +16,7 @@ int main() { cin >> S; SuffixArray sa(S); cin >> Q; - while(Q--) { + while (Q--) { string T; cin >> T; auto range = sa.equal_range(T); diff --git a/test/verify/aoj-alds-1-9-c.test.cpp b/test/verify/aoj-alds-1-9-c.test.cpp index 2bffa294..74244dfb 100644 --- a/test/verify/aoj-alds-1-9-c.test.cpp +++ b/test/verify/aoj-alds-1-9-c.test.cpp @@ -1,15 +1,20 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_C +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../structure/heap/leftist-heap.hpp" +using namespace std; + int main() { string s; - LeftistHeap< int, false > que; + LeftistHeap que; auto root = que.make_root(); - while(cin >> s, s != "end") { - if(s == "insert") { + while (cin >> s, s != "end") { + if (s == "insert") { int x; cin >> x; root = que.push(root, x); diff --git a/test/verify/aoj-cgl-1-a.test.cpp b/test/verify/aoj-cgl-1-a.test.cpp index 1083bcf8..a350bdc9 100644 --- a/test/verify/aoj-cgl-1-a.test.cpp +++ b/test/verify/aoj-cgl-1-a.test.cpp @@ -1,18 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A +// clang-format on // competitive-verifier: ERROR 0.00000001 -#include "../../template/template.hpp" +#include +#include #include "../../geometry/projection.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); Line l; cin >> l; int Q; cin >> Q; - while(Q--) { + while (Q--) { Point p; cin >> p; cout << projection(l, p) << "\n"; diff --git a/test/verify/aoj-cgl-1-b.test.cpp b/test/verify/aoj-cgl-1-b.test.cpp index 184a105e..09dfe519 100644 --- a/test/verify/aoj-cgl-1-b.test.cpp +++ b/test/verify/aoj-cgl-1-b.test.cpp @@ -1,18 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B +// clang-format on // competitive-verifier: ERROR 0.00000001 -#include "../../template/template.hpp" +#include +#include #include "../../geometry/reflection.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); Line l; cin >> l; int Q; cin >> Q; - while(Q--) { + while (Q--) { Point p; cin >> p; cout << reflection(l, p) << "\n"; diff --git a/test/verify/aoj-cgl-1-c.test.cpp b/test/verify/aoj-cgl-1-c.test.cpp index 6a912b0b..6a0b63e7 100644 --- a/test/verify/aoj-cgl-1-c.test.cpp +++ b/test/verify/aoj-cgl-1-c.test.cpp @@ -1,24 +1,34 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../geometry/ccw.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); Point p1, p2; cin >> p1 >> p2; int Q; cin >> Q; - while(Q--) { + while (Q--) { Point p3; cin >> p3; auto t = ccw(p1, p2, p3); - if(t == 1) cout << "COUNTER_CLOCKWISE\n"; - else if(t == -1) cout << "CLOCKWISE\n"; - else if(t == 2) cout << "ONLINE_BACK\n"; - else if(t == -2) cout << "ONLINE_FRONT\n"; - else cout << "ON_SEGMENT\n"; + if (t == 1) + cout << "COUNTER_CLOCKWISE\n"; + else if (t == -1) + cout << "CLOCKWISE\n"; + else if (t == 2) + cout << "ONLINE_BACK\n"; + else if (t == -2) + cout << "ONLINE_FRONT\n"; + else + cout << "ON_SEGMENT\n"; } } diff --git a/test/verify/aoj-cgl-2-a.test.cpp b/test/verify/aoj-cgl-2-a.test.cpp index e72530b9..85099cac 100644 --- a/test/verify/aoj-cgl-2-a.test.cpp +++ b/test/verify/aoj-cgl-2-a.test.cpp @@ -1,20 +1,28 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A +// clang-format on -#include "../../template/template.hpp" +#include +#include -#include "../../geometry/is_parallel.hpp" #include "../../geometry/is_orthogonal.hpp" +#include "../../geometry/is_parallel.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int Q; cin >> Q; - while(Q--) { + while (Q--) { Line s1, s2; cin >> s1 >> s2; - if(is_parallel(s1, s2)) cout << "2\n"; - else if(is_orthogonal(s1, s2)) cout << "1\n"; - else cout << "0\n"; + if (is_parallel(s1, s2)) + cout << "2\n"; + else if (is_orthogonal(s1, s2)) + cout << "1\n"; + else + cout << "0\n"; } } diff --git a/test/verify/aoj-cgl-2-b.test.cpp b/test/verify/aoj-cgl-2-b.test.cpp index e4c8552e..c09f87c6 100644 --- a/test/verify/aoj-cgl-2-b.test.cpp +++ b/test/verify/aoj-cgl-2-b.test.cpp @@ -1,15 +1,20 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../geometry/is_intersect_ss.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int T; cin >> T; - while(T--) { + while (T--) { Segment a, b; cin >> a >> b; cout << is_intersect_ss(a, b) << "\n"; diff --git a/test/verify/aoj-cgl-2-c.test.cpp b/test/verify/aoj-cgl-2-c.test.cpp index 0cd17074..c868a449 100644 --- a/test/verify/aoj-cgl-2-c.test.cpp +++ b/test/verify/aoj-cgl-2-c.test.cpp @@ -1,16 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_C +// clang-format on // competitive-verifier: ERROR 0.00000001 -#include "../../template/template.hpp" +#include +#include #include "../../geometry/cross_point_ll.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int T; cin >> T; - while(T--) { + while (T--) { Line a, b; cin >> a >> b; cout << cross_point_ll(a, b) << "\n"; diff --git a/test/verify/aoj-cgl-2-d.test.cpp b/test/verify/aoj-cgl-2-d.test.cpp index f008d618..97a42e00 100644 --- a/test/verify/aoj-cgl-2-d.test.cpp +++ b/test/verify/aoj-cgl-2-d.test.cpp @@ -1,16 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_D +// clang-format on // competitive-verifier: ERROR 0.00000001 -#include "../../template/template.hpp" +#include +#include #include "../../geometry/distance_ss.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int T; cin >> T; - while(T--) { + while (T--) { Segment a, b; cin >> a >> b; cout << distance_ss(a, b) << "\n"; diff --git a/test/verify/aoj-cgl-3-a.test.cpp b/test/verify/aoj-cgl-3-a.test.cpp index 9c2a2add..15fdd697 100644 --- a/test/verify/aoj-cgl-3-a.test.cpp +++ b/test/verify/aoj-cgl-3-a.test.cpp @@ -1,15 +1,20 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../geometry/area.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int N; cin >> N; Polygon p(N); - for(auto &s : p) cin >> s; + for (auto& s : p) cin >> s; cout << fixed << setprecision(1) << area(p) << "\n"; } diff --git a/test/verify/aoj-cgl-3-b.test.cpp b/test/verify/aoj-cgl-3-b.test.cpp index 0a02f2e6..88af1ac0 100644 --- a/test/verify/aoj-cgl-3-b.test.cpp +++ b/test/verify/aoj-cgl-3-b.test.cpp @@ -1,15 +1,20 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_B +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../geometry/is_convex_polygon.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int N; cin >> N; Polygon p(N); - for(auto &s : p) cin >> s; + for (auto& s : p) cin >> s; cout << is_convex_polygon(p) << endl; } diff --git a/test/verify/aoj-cgl-3-c.test.cpp b/test/verify/aoj-cgl-3-c.test.cpp index 4264144e..31e617ee 100644 --- a/test/verify/aoj-cgl-3-c.test.cpp +++ b/test/verify/aoj-cgl-3-c.test.cpp @@ -1,21 +1,26 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_C +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../geometry/contains.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int N; cin >> N; Polygon p(N); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { cin >> p[i]; } int Q; cin >> Q; - while(Q--) { + while (Q--) { Point q; cin >> q; cout << contains(p, q) << "\n"; diff --git a/test/verify/aoj-cgl-4-a.test.cpp b/test/verify/aoj-cgl-4-a.test.cpp index b988e7f5..6926e07b 100644 --- a/test/verify/aoj-cgl-4-a.test.cpp +++ b/test/verify/aoj-cgl-4-a.test.cpp @@ -1,26 +1,31 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_A +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../geometry/convex_hull.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int N; cin >> N; Polygon p(N); - for(auto &s : p) cin >> s; + for (auto& s : p) cin >> s; p = convex_hull(p, false); - N = (int) p.size(); + N = (int)p.size(); cout << N << "\n"; int idx = 0; - for(int i = 1; i < N; i++) { - if(compare_y(p[i], p[idx])) { + for (int i = 1; i < N; i++) { + if (compare_y(p[i], p[idx])) { idx = i; } } - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { cout << fixed << setprecision(0) << p[(idx + i) % N] << "\n"; } } diff --git a/test/verify/aoj-cgl-4-b.test.cpp b/test/verify/aoj-cgl-4-b.test.cpp index 3844bc6b..9d88dffb 100644 --- a/test/verify/aoj-cgl-4-b.test.cpp +++ b/test/verify/aoj-cgl-4-b.test.cpp @@ -1,17 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_B +// clang-format on // competitive-verifier: ERROR 0.00000001 -#include "../../template/template.hpp" +#include +#include +#include #include "../../geometry/convex_polygon_diameter.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int N; cin >> N; Polygon p(N); - for(int i = 0; i < N; i++) { + for (int i = 0; i < N; i++) { cin >> p[i]; } auto ret = convex_polygon_diameter(p); diff --git a/test/verify/aoj-cgl-4-c.test.cpp b/test/verify/aoj-cgl-4-c.test.cpp index cddfb58f..98cd9422 100644 --- a/test/verify/aoj-cgl-4-c.test.cpp +++ b/test/verify/aoj-cgl-4-c.test.cpp @@ -1,23 +1,28 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_4_C +// clang-format on // competitive-verifier: ERROR 0.00001 -#include "../../template/template.hpp" +#include +#include -#include "../../geometry/convex_polygon_cut.hpp" #include "../../geometry/area.hpp" +#include "../../geometry/convex_polygon_cut.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int n; cin >> n; Polygon poly(n); - for(auto &p : poly) { + for (auto& p : poly) { cin >> p; } int q; cin >> q; - while(q--) { + while (q--) { Line l; cin >> l; cout << area(convex_polygon_cut(poly, l)) << "\n"; diff --git a/test/verify/aoj-cgl-7-d.test.cpp b/test/verify/aoj-cgl-7-d.test.cpp index 03fa8e34..c5f1629a 100644 --- a/test/verify/aoj-cgl-7-d.test.cpp +++ b/test/verify/aoj-cgl-7-d.test.cpp @@ -1,23 +1,29 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_D +// clang-format on // competitive-verifier: ERROR 0.000001 -#include "../../template/template.hpp" +#include +#include +#include #include "../../geometry/cross_point_cl.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); Circle c; cin >> c.p >> c.r; int Q; cin >> Q; - while(Q--) { + while (Q--) { Line l; cin >> l; auto ret = cross_point_cl(c, l); - if(ret.size() == 1) ret.emplace_back(ret[0]); - if(!compare_x(ret[0], ret[1])) swap(ret[0], ret[1]); + if (ret.size() == 1) ret.emplace_back(ret[0]); + if (!compare_x(ret[0], ret[1])) swap(ret[0], ret[1]); cout << ret[0] << " " << ret[1] << "\n"; } } diff --git a/test/verify/aoj-cgl-7-e.test.cpp b/test/verify/aoj-cgl-7-e.test.cpp index 4fcc5975..d9ac7c39 100644 --- a/test/verify/aoj-cgl-7-e.test.cpp +++ b/test/verify/aoj-cgl-7-e.test.cpp @@ -1,17 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_E +// clang-format on // competitive-verifier: ERROR 0.000001 -#include "../../template/template.hpp" +#include +#include +#include #include "../../geometry/cross_point_cc.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); Circle x, y; cin >> x.p >> x.r >> y.p >> y.r; auto ret = cross_point_cc(x, y); - if(ret.size() == 1) ret.emplace_back(ret[0]); - if(!compare_x(ret[0], ret[1])) swap(ret[0], ret[1]); + if (ret.size() == 1) ret.emplace_back(ret[0]); + if (!compare_x(ret[0], ret[1])) swap(ret[0], ret[1]); cout << ret[0] << " " << ret[1] << "\n"; } diff --git a/test/verify/aoj-cgl-7-h.test.cpp b/test/verify/aoj-cgl-7-h.test.cpp index 27e575d5..7547ecb0 100644 --- a/test/verify/aoj-cgl-7-h.test.cpp +++ b/test/verify/aoj-cgl-7-h.test.cpp @@ -1,18 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_H +// clang-format on // competitive-verifier: ERROR 0.00001 -#include "../../template/template.hpp" +#include +#include #include "../../geometry/common_area_cp.hpp" +using namespace std; using namespace geometry; int main() { + cout << fixed << setprecision(10); int N; Real R; cin >> N >> R; Circle c(Point(0, 0), R); Polygon p(N); - for(auto &s : p) cin >> s; + for (auto& s : p) cin >> s; cout << common_area_cp(c, p) << endl; } diff --git a/test/verify/aoj-dpl-1-b.test.cpp b/test/verify/aoj-dpl-1-b.test.cpp index 8aea5fef..f56b2d3d 100644 --- a/test/verify/aoj-dpl-1-b.test.cpp +++ b/test/verify/aoj-dpl-1-b.test.cpp @@ -1,14 +1,20 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_B +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../dp/knapsack-01.hpp" +using namespace std; + int main() { int N, W; cin >> N >> W; - vector< int > v(N), w(N); - for(int i = 0; i < N; i++) cin >> v[i] >> w[i]; + vector v(N), w(N); + for (int i = 0; i < N; i++) cin >> v[i] >> w[i]; auto ret = knapsack_01(w, v, W, -1); - cout << *max_element(begin(ret), end(ret)) << endl; + cout << *max_element(ret.begin(), ret.end()) << endl; } diff --git a/test/verify/aoj-dpl-1-c.test.cpp b/test/verify/aoj-dpl-1-c.test.cpp index 0ccc7e43..9b99ba0f 100644 --- a/test/verify/aoj-dpl-1-c.test.cpp +++ b/test/verify/aoj-dpl-1-c.test.cpp @@ -1,14 +1,20 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_C +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../dp/knapsack.hpp" +using namespace std; + int main() { int N, W; cin >> N >> W; - vector< int > v(N), w(N); - for(int i = 0; i < N; i++) cin >> v[i] >> w[i]; + vector v(N), w(N); + for (int i = 0; i < N; i++) cin >> v[i] >> w[i]; auto ret = knapsack(w, v, W, -1); - cout << *max_element(begin(ret), end(ret)) << endl; + cout << *max_element(ret.begin(), ret.end()) << endl; } diff --git a/test/verify/aoj-dpl-1-d.test.cpp b/test/verify/aoj-dpl-1-d.test.cpp index 6322de13..59582a27 100644 --- a/test/verify/aoj-dpl-1-d.test.cpp +++ b/test/verify/aoj-dpl-1-d.test.cpp @@ -1,13 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../dp/longest-increasing-subsequence.hpp" +using namespace std; + int main() { int N; cin >> N; - vector< int > A(N); - cin >> A; + vector A(N); + for (int& a : A) cin >> a; cout << longest_increasing_subsequence(A, true) << endl; } diff --git a/test/verify/aoj-dpl-1-e.test.cpp b/test/verify/aoj-dpl-1-e.test.cpp index 15175cba..c574d0b7 100644 --- a/test/verify/aoj-dpl-1-e.test.cpp +++ b/test/verify/aoj-dpl-1-e.test.cpp @@ -1,12 +1,16 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../dp/edit-distance.hpp" +using namespace std; + int main() { string S, T; cin >> S >> T; cout << edit_distance(S, T) << endl; } - diff --git a/test/verify/aoj-dpl-1-f.test.cpp b/test/verify/aoj-dpl-1-f.test.cpp index 87c6cc44..82705a68 100644 --- a/test/verify/aoj-dpl-1-f.test.cpp +++ b/test/verify/aoj-dpl-1-f.test.cpp @@ -1,13 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_F +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../dp/knapsack-01-2.hpp" +using namespace std; + int main() { int N, W; cin >> N >> W; - vector< int > v(N), w(N); - for(int i = 0; i < N; i++) cin >> v[i] >> w[i]; + vector v(N), w(N); + for (int i = 0; i < N; i++) cin >> v[i] >> w[i]; cout << knapsack_01_2(w, v, W) << endl; } diff --git a/test/verify/aoj-dpl-1-i.test.cpp b/test/verify/aoj-dpl-1-i.test.cpp index 223b4712..394fb8b2 100644 --- a/test/verify/aoj-dpl-1-i.test.cpp +++ b/test/verify/aoj-dpl-1-i.test.cpp @@ -1,16 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_I +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../dp/knapsack-limitations-2.hpp" +using namespace std; + int main() { int N; - int64 W; + long long W; cin >> N >> W; - vector< int > v(N); - vector< int64 > w(N), m(N); - for(int i = 0; i < N; i++) { + vector v(N); + vector w(N), m(N); + for (int i = 0; i < N; i++) { cin >> v[i] >> w[i] >> m[i]; } cout << knapsack_limitations(w, m, v, W) << endl; diff --git a/test/verify/aoj-dpl-3-c.test.cpp b/test/verify/aoj-dpl-3-c.test.cpp index 1c43f55d..659bb219 100644 --- a/test/verify/aoj-dpl-3-c.test.cpp +++ b/test/verify/aoj-dpl-3-c.test.cpp @@ -1,13 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_3_C +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../dp/largest-rectangle.hpp" +using namespace std; + int main() { int N; cin >> N; - vector< int > h(N); - cin >> h; + vector h(N); + for (int& height : h) cin >> height; cout << largest_rectangle(h) << endl; } diff --git a/test/verify/aoj-dpl-5-g.test.cpp b/test/verify/aoj-dpl-5-g.test.cpp index 05995d2f..39c1d4c7 100644 --- a/test/verify/aoj-dpl-5-g.test.cpp +++ b/test/verify/aoj-dpl-5-g.test.cpp @@ -1,13 +1,16 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_5_G +// clang-format on -#include "../../template/template.hpp" +#include +#include "../../math/combinatorics/bell-number.hpp" #include "../../math/combinatorics/montgomery-mod-int.hpp" -#include "../../math/combinatorics/bell-number.hpp" +using namespace std; int main() { int N, K; cin >> N >> K; - cout << bell_number< modint1000000007 >(N, K) << endl; + cout << bell_number(N, K) << endl; } diff --git a/test/verify/aoj-dpl-5-i.test.cpp b/test/verify/aoj-dpl-5-i.test.cpp index a3edc5ea..d9b9d05b 100644 --- a/test/verify/aoj-dpl-5-i.test.cpp +++ b/test/verify/aoj-dpl-5-i.test.cpp @@ -1,14 +1,16 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_5_I +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/combinatorics/montgomery-mod-int.hpp" - #include "../../math/combinatorics/stirling-number-second.hpp" +using namespace std; + int main() { int N, K; cin >> N >> K; - cout << stirling_number_second< modint1000000007 >(N, K) << endl; + cout << stirling_number_second(N, K) << endl; } - diff --git a/test/verify/aoj-dpl-5-j.test.cpp b/test/verify/aoj-dpl-5-j.test.cpp index d87401fb..c8b2d3e7 100644 --- a/test/verify/aoj-dpl-5-j.test.cpp +++ b/test/verify/aoj-dpl-5-j.test.cpp @@ -1,13 +1,16 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_5_J +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/combinatorics/montgomery-mod-int.hpp" - #include "../../math/combinatorics/partition-table.hpp" +using namespace std; + int main() { int N, K; cin >> N >> K; - cout << partition_table< modint1000000007 >(N, K)[N][K] << endl; + cout << partition_table(N, K)[N][K] << endl; } diff --git a/test/verify/aoj-dsl-1-a.test.cpp b/test/verify/aoj-dsl-1-a.test.cpp index ea788c04..a4306ba0 100644 --- a/test/verify/aoj-dsl-1-a.test.cpp +++ b/test/verify/aoj-dsl-1-a.test.cpp @@ -1,17 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../structure/union-find/union-find.hpp" +using namespace std; + int main() { int N, Q; scanf("%d %d", &N, &Q); UnionFind uf(N); - while(Q--) { + while (Q--) { int t, x, y; scanf("%d %d %d", &t, &x, &y); - if(t == 0) uf.unite(x, y); - else printf("%d\n", uf.find(x) == uf.find(y)); + if (t == 0) + uf.unite(x, y); + else + printf("%d\n", uf.find(x) == uf.find(y)); } } diff --git a/test/verify/aoj-dsl-1-b.test.cpp b/test/verify/aoj-dsl-1-b.test.cpp index e4ced038..7e55eeff 100644 --- a/test/verify/aoj-dsl-1-b.test.cpp +++ b/test/verify/aoj-dsl-1-b.test.cpp @@ -1,21 +1,25 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_B +// clang-format on -#include "../../template/template.hpp" +#include #include "../../structure/union-find/weighted-union-find.hpp" +using namespace std; + int main() { int N, M; cin >> N >> M; - WeightedUnionFind< int > tree(N); - while(M--) { + WeightedUnionFind tree(N); + while (M--) { int A, B, C, D; cin >> A >> B >> C; - if(A == 0) { + if (A == 0) { cin >> D; tree.unite(B, C, D); } else { - if(tree.find(B) == tree.find(C)) { + if (tree.find(B) == tree.find(C)) { cout << tree.diff(B, C) << endl; } else { cout << "?" << endl; diff --git a/test/verify/aoj-dsl-2-a.test.cpp b/test/verify/aoj-dsl-2-a.test.cpp index 78a8e14a..0fb18349 100644 --- a/test/verify/aoj-dsl-2-a.test.cpp +++ b/test/verify/aoj-dsl-2-a.test.cpp @@ -1,19 +1,27 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../structure/segment-tree/segment-tree.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - auto seg = SegmentTree( - LambdaMonoid([](int a, int b) { return min(a, b); }, - []() { return INT_MAX; }), N); + auto seg = SegmentTree(LambdaMonoid([](int a, int b) { return min(a, b); }, + []() { return INT_MAX; }), + N); while (Q--) { int T, X, Y; cin >> T >> X >> Y; - if (T == 0) seg.set(X, Y); - else cout << seg.prod(X, Y + 1) << "\n"; + if (T == 0) + seg.set(X, Y); + else + cout << seg.prod(X, Y + 1) << "\n"; } } diff --git a/test/verify/aoj-dsl-2-b-2.test.cpp b/test/verify/aoj-dsl-2-b-2.test.cpp index 5818397d..3cd6bec5 100644 --- a/test/verify/aoj-dsl-2-b-2.test.cpp +++ b/test/verify/aoj-dsl-2-b-2.test.cpp @@ -1,19 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B +// clang-format on -#include "../../template/template.hpp" +#include #include "../../structure/trie/binary-trie.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - BinaryTrie< int, 20 > bt; - for(int i = 0; i < Q; i++) { + BinaryTrie bt; + for (int i = 0; i < Q; i++) { int c, x, y; cin >> c >> x >> y; - if(c == 0) { + if (c == 0) { bt.add(x, -1, y); - } else if(c == 1) { + } else if (c == 1) { cout << bt.count_less(y + 1) - bt.count_less(x) << "\n"; } } diff --git a/test/verify/aoj-dsl-2-b.test.cpp b/test/verify/aoj-dsl-2-b.test.cpp index 9fdb1e35..75fb2e9d 100644 --- a/test/verify/aoj-dsl-2-b.test.cpp +++ b/test/verify/aoj-dsl-2-b.test.cpp @@ -1,17 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B +// clang-format on -#include "../../template/template.hpp" +#include #include "../../structure/others/binary-indexed-tree.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - BinaryIndexedTree< int > bit(N); - while(Q--) { + BinaryIndexedTree bit(N); + while (Q--) { int T, X, Y; cin >> T >> X >> Y; - if(T == 0) bit.apply(X - 1, Y); - else cout << bit.prod(X - 1, Y) << "\n"; + if (T == 0) + bit.apply(X - 1, Y); + else + cout << bit.prod(X - 1, Y) << "\n"; } } diff --git a/test/verify/aoj-dsl-2-d.test.cpp b/test/verify/aoj-dsl-2-d.test.cpp index 5dd08c4c..dfce933c 100644 --- a/test/verify/aoj-dsl-2-d.test.cpp +++ b/test/verify/aoj-dsl-2-d.test.cpp @@ -1,23 +1,28 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_D +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../structure/segment-tree/dual-segment-tree.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - auto h = [](int a, int b) { return b; }; + auto h = [](int, int b) { return b; }; auto id = []() { return INT_MAX; }; DualSegmentTree seg(LambdaAct(h, id), N); - while(Q--) { + while (Q--) { int com; cin >> com; - if(com == 0) { + if (com == 0) { int l, r, x; cin >> l >> r >> x; seg.apply(l, r + 1, x); - } else if(com == 1) { + } else if (com == 1) { int k; cin >> k; cout << seg[k] << "\n"; diff --git a/test/verify/aoj-grl-1-a-2.test.cpp b/test/verify/aoj-grl-1-a-2.test.cpp index 8c3ffbf4..37f5c5fd 100644 --- a/test/verify/aoj-grl-1-a-2.test.cpp +++ b/test/verify/aoj-grl-1-a-2.test.cpp @@ -1,16 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../graph/shortest-path/dijkstra-fibonacchi-heap.hpp" +using namespace std; + int main() { int V, E, R; cin >> V >> E >> R; - Graph< int > g(V); + Graph g(V); g.read(E, 0, true, true); - for(auto &dist : dijkstra_fibonacchi_heap(g, R)) { - if(dist == numeric_limits< int >::max()) cout << "INF\n"; - else cout << dist << "\n"; + for (auto& dist : dijkstra_fibonacchi_heap(g, R)) { + if (dist == numeric_limits::max()) + cout << "INF\n"; + else + cout << dist << "\n"; } } diff --git a/test/verify/aoj-grl-1-a-3.test.cpp b/test/verify/aoj-grl-1-a-3.test.cpp index b18a591f..ef5135c9 100644 --- a/test/verify/aoj-grl-1-a-3.test.cpp +++ b/test/verify/aoj-grl-1-a-3.test.cpp @@ -1,18 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A +// clang-format on -#include "../../template/template.hpp" - -#include "../../structure/heap/radix-heap.hpp" +#include +#include #include "../../graph/shortest-path/dijkstra-radix-heap.hpp" +using namespace std; + int main() { int V, E, R; cin >> V >> E >> R; - Graph< int > g(V); + Graph g(V); g.read(E, 0, true, true); - for(auto &dist : dijkstra_radix_heap(g, R)) { - if(dist == numeric_limits< int >::max()) cout << "INF\n"; - else cout << dist << "\n"; + for (auto& dist : dijkstra_radix_heap(g, R)) { + if (dist == numeric_limits::max()) + cout << "INF\n"; + else + cout << dist << "\n"; } } diff --git a/test/verify/aoj-grl-1-a.test.cpp b/test/verify/aoj-grl-1-a.test.cpp index fb64bff8..eb683656 100644 --- a/test/verify/aoj-grl-1-a.test.cpp +++ b/test/verify/aoj-grl-1-a.test.cpp @@ -1,16 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../graph/shortest-path/dijkstra.hpp" +using namespace std; + int main() { int V, E, R; cin >> V >> E >> R; - Graph< int > g(V); + Graph g(V); g.read(E, 0, true, true); - for(auto &dist : dijkstra(g, R).dist) { - if(dist == numeric_limits< int >::max()) cout << "INF\n"; - else cout << dist << "\n"; + for (auto& dist : dijkstra(g, R).dist) { + if (dist == numeric_limits::max()) + cout << "INF\n"; + else + cout << dist << "\n"; } } diff --git a/test/verify/aoj-grl-1-b-2.test.cpp b/test/verify/aoj-grl-1-b-2.test.cpp index 767822aa..c72b13df 100644 --- a/test/verify/aoj-grl-1-b-2.test.cpp +++ b/test/verify/aoj-grl-1-b-2.test.cpp @@ -1,18 +1,25 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_B +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../graph/shortest-path/shortest-path-faster-algorithm.hpp" +using namespace std; + int main() { int V, E, R; cin >> V >> E >> R; - Graph< int > g(V); + Graph g(V); g.read(E, 0, true, true); auto dists = shortest_path_faster_algorithm(g, R); - if(dists.empty()) cout << "NEGATIVE CYCLE\n"; - for(auto &dist : dists) { - if(dist == numeric_limits< int >::max()) cout << "INF\n"; - else cout << dist << "\n"; + if (dists.empty()) cout << "NEGATIVE CYCLE\n"; + for (auto& dist : dists) { + if (dist == numeric_limits::max()) + cout << "INF\n"; + else + cout << dist << "\n"; } } diff --git a/test/verify/aoj-grl-1-b.test.cpp b/test/verify/aoj-grl-1-b.test.cpp index 4fa45352..0e3b831a 100644 --- a/test/verify/aoj-grl-1-b.test.cpp +++ b/test/verify/aoj-grl-1-b.test.cpp @@ -1,27 +1,34 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_B +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../graph/shortest-path/bellman-ford.hpp" +using namespace std; + int main() { int V, E, R; cin >> V >> E >> R; - Edges< > es; - for(int i = 0; i < E; i++) { + Edges<> es; + for (int i = 0; i < E; i++) { int a, b, c; cin >> a >> b >> c; es.emplace_back(a, b, c); } auto dists = bellman_ford(es, V, R); - for(auto& dist : dists) { - if(dist == numeric_limits< int >::min()) { + for (auto& dist : dists) { + if (dist == numeric_limits::min()) { cout << "NEGATIVE CYCLE\n"; return 0; } } - for(auto &dist : dists) { - if(dist == numeric_limits< int >::max()) cout << "INF\n"; - else cout << dist << "\n"; + for (auto& dist : dists) { + if (dist == numeric_limits::max()) + cout << "INF\n"; + else + cout << dist << "\n"; } } diff --git a/test/verify/aoj-grl-1-c.test.cpp b/test/verify/aoj-grl-1-c.test.cpp index e665b83d..185a7b7c 100644 --- a/test/verify/aoj-grl-1-c.test.cpp +++ b/test/verify/aoj-grl-1-c.test.cpp @@ -1,36 +1,43 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C +// clang-format on -#include "../../template/template.hpp" +#include +#include -#include "../../math/matrix/square-matrix.hpp" #include "../../graph/shortest-path/warshall-floyd.hpp" +#include "../../math/matrix/square-matrix.hpp" + +using namespace std; int main() { int V, E; scanf("%d %d", &V, &E); - SquareMatrix< int, 100 > mat; - for(int i = 0; i < 100; i++) { - for(int j = 0; j < 100; j++) { - if(i != j) mat[i][j] = INT_MAX; + SquareMatrix mat; + for (int i = 0; i < 100; i++) { + for (int j = 0; j < 100; j++) { + if (i != j) mat[i][j] = INT_MAX; } } - for(int i = 0; i < E; i++) { + for (int i = 0; i < E; i++) { int x, y, z; scanf("%d %d %d", &x, &y, &z); mat[x][y] = z; } warshall_floyd(mat, INT_MAX); - for(int i = 0; i < V; i++) { - if(mat[i][i] < 0) { + for (int i = 0; i < V; i++) { + if (mat[i][i] < 0) { puts("NEGATIVE CYCLE"); return 0; } } - for(int i = 0; i < V; i++) { - for(int j = 0; j < V; j++) { - if(j > 0) putchar(' '); - if(mat[i][j] == INT_MAX) printf("INF"); - else printf("%d", mat[i][j]); + for (int i = 0; i < V; i++) { + for (int j = 0; j < V; j++) { + if (j > 0) putchar(' '); + if (mat[i][j] == INT_MAX) + printf("INF"); + else + printf("%d", mat[i][j]); } putchar('\n'); } diff --git a/test/verify/aoj-grl-2-a-2.test.cpp b/test/verify/aoj-grl-2-a-2.test.cpp index b5a48084..b8bdca01 100644 --- a/test/verify/aoj-grl-2-a-2.test.cpp +++ b/test/verify/aoj-grl-2-a-2.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/mst/kruskal.hpp" +using namespace std; + int main() { int V, E; cin >> V >> E; - Edges< int > edges; - for(int i = 0; i < E; i++) { + Edges edges; + for (int i = 0; i < E; i++) { int a, b, c; cin >> a >> b >> c; edges.emplace_back(a, b, c); diff --git a/test/verify/aoj-grl-2-a-3.test.cpp b/test/verify/aoj-grl-2-a-3.test.cpp index 54eed4ba..76228ed3 100644 --- a/test/verify/aoj-grl-2-a-3.test.cpp +++ b/test/verify/aoj-grl-2-a-3.test.cpp @@ -1,22 +1,29 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include +#include #include "../../graph/mst/boruvka.hpp" +using namespace std; + int main() { int V, E; cin >> V >> E; - vector< int > X(E), Y(E), Z(E); - for(int i = 0; i < E; i++) { + vector X(E), Y(E), Z(E); + for (int i = 0; i < E; i++) { cin >> X[i] >> Y[i] >> Z[i]; } - Boruvka< int > mst(V); - auto f = [&](vector< pair< int, int > > &ret) { - for(int i = 0; i < E; i++) { + Boruvka mst(V); + auto f = [&](vector>& ret) { + for (int i = 0; i < E; i++) { X[i] = mst.find(X[i]); Y[i] = mst.find(Y[i]); - if(X[i] == Y[i]) continue; + if (X[i] == Y[i]) continue; ret[X[i]] = min(ret[X[i]], make_pair(Z[i], Y[i])); ret[Y[i]] = min(ret[Y[i]], make_pair(Z[i], X[i])); } diff --git a/test/verify/aoj-grl-2-a-4.test.cpp b/test/verify/aoj-grl-2-a-4.test.cpp index 06c2f14a..fca4c961 100644 --- a/test/verify/aoj-grl-2-a-4.test.cpp +++ b/test/verify/aoj-grl-2-a-4.test.cpp @@ -1,9 +1,13 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/mst/prim-fibonacchi-heap.hpp" +using namespace std; + int main() { int V, E; cin >> V >> E; diff --git a/test/verify/aoj-grl-2-a.test.cpp b/test/verify/aoj-grl-2-a.test.cpp index 3ff531e3..aa038a55 100644 --- a/test/verify/aoj-grl-2-a.test.cpp +++ b/test/verify/aoj-grl-2-a.test.cpp @@ -1,9 +1,13 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/mst/prim.hpp" +using namespace std; + int main() { int V, E; cin >> V >> E; diff --git a/test/verify/aoj-grl-2-b.test.cpp b/test/verify/aoj-grl-2-b.test.cpp index 3a03612d..1f051e8f 100644 --- a/test/verify/aoj-grl-2-b.test.cpp +++ b/test/verify/aoj-grl-2-b.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_B +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/mst/directed-mst.hpp" +using namespace std; + int main() { int V, E, R; cin >> V >> E >> R; - Edges< int > edges; - for(int i = 0; i < E; i++) { + Edges edges; + for (int i = 0; i < E; i++) { int a, b, c; cin >> a >> b >> c; edges.emplace_back(a, b, c); diff --git a/test/verify/aoj-grl-3-a.test.cpp b/test/verify/aoj-grl-3-a.test.cpp index 6a7e30d5..8f9f3e46 100644 --- a/test/verify/aoj-grl-3-a.test.cpp +++ b/test/verify/aoj-grl-3-a.test.cpp @@ -1,17 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_A +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../graph/others/low-link.hpp" +using namespace std; + int main() { int V, E; cin >> V >> E; LowLink<> g(V); g.read(E, 0); g.build(); - auto &art = g.articulation; + auto& art = g.articulation; sort(art.begin(), art.end()); - for(auto &v : art) cout << v << "\n"; + for (auto& v : art) cout << v << "\n"; } - diff --git a/test/verify/aoj-grl-3-b.test.cpp b/test/verify/aoj-grl-3-b.test.cpp index cda52149..a373e97f 100644 --- a/test/verify/aoj-grl-3-b.test.cpp +++ b/test/verify/aoj-grl-3-b.test.cpp @@ -1,17 +1,24 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_B +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../graph/others/low-link.hpp" +using namespace std; + int main() { int V, E; cin >> V >> E; LowLink<> g(V); g.read(E, 0); g.build(); - auto &bridge = g.bridge; - for(auto &v : bridge) tie(v.from, v.to) = minmax({v.from, v.to}); - sort(bridge.begin(), bridge.end(), [](auto &p, auto &q) { return tie(p.from, p.to) < tie(q.from, q.to); }); - for(auto &v : bridge) cout << v.from << " " << v.to << "\n"; + auto& bridge = g.bridge; + for (auto& v : bridge) tie(v.from, v.to) = minmax({v.from, v.to}); + sort(bridge.begin(), bridge.end(), + [](auto& p, auto& q) { return tie(p.from, p.to) < tie(q.from, q.to); }); + for (auto& v : bridge) cout << v.from << " " << v.to << "\n"; } diff --git a/test/verify/aoj-grl-3-c.test.cpp b/test/verify/aoj-grl-3-c.test.cpp index 0880218d..9f5a8ec5 100644 --- a/test/verify/aoj-grl-3-c.test.cpp +++ b/test/verify/aoj-grl-3-c.test.cpp @@ -1,9 +1,13 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_C +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/connected-components/strongly-connected-components.hpp" +using namespace std; + int main() { int V, E, Q; cin >> V >> E; @@ -11,9 +15,9 @@ int main() { scc.read(E, false, 0, true); scc.build(); cin >> Q; - while(Q--) { + while (Q--) { int a, b; cin >> a >> b; - cout << (int) (scc[a] == scc[b]) << "\n"; + cout << static_cast(scc[a] == scc[b]) << "\n"; } } diff --git a/test/verify/aoj-grl-5-a-3.test.cpp b/test/verify/aoj-grl-5-a-3.test.cpp index 9c803a6b..b12c9ff3 100644 --- a/test/verify/aoj-grl-5-a-3.test.cpp +++ b/test/verify/aoj-grl-5-a-3.test.cpp @@ -1,19 +1,24 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_A +// clang-format on + +#include -#include "../../template/template.hpp" #include "../../structure/dynamic-tree/diameter.hpp" #include "../../structure/dynamic-tree/dynamic-tree-builder-for-edge.hpp" +using namespace std; + int main() { int N; cin >> N; - DynamicTreeBuilderForEdge< TopTree, Diameter< int64 > > g(N); - for(int i = 0; i < N; i++) { + DynamicTreeBuilderForEdge > g(N); + for (int i = 0; i < N; i++) { g.set_vertex(i, {true, 0}); } - for(int i = 1; i < N; i++) { + for (int i = 1; i < N; i++) { int a, b; - int64 w; + long long w; cin >> a >> b >> w; g.add_edge(a, b, {false, w}); } diff --git a/test/verify/aoj-grl-5-a.test.cpp b/test/verify/aoj-grl-5-a.test.cpp index d05780ee..c98fe576 100644 --- a/test/verify/aoj-grl-5-a.test.cpp +++ b/test/verify/aoj-grl-5-a.test.cpp @@ -1,13 +1,17 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/tree/tree-diameter.hpp" +using namespace std; + int main() { int N; cin >> N; - TreeDiameter< int > g(N); + TreeDiameter g(N); g.read(N - 1, 0, true); cout << g.build() << endl; } diff --git a/test/verify/aoj-grl-5-c-2.test.cpp b/test/verify/aoj-grl-5-c-2.test.cpp index 67740773..0de9cad3 100644 --- a/test/verify/aoj-grl-5-c-2.test.cpp +++ b/test/verify/aoj-grl-5-c-2.test.cpp @@ -1,17 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/tree/heavy-light-decomposition.hpp" +using namespace std; + int main() { int N, Q; cin >> N; - HeavyLightDecomposition< int > hld(N); - for(int i = 0; i < N; i++) { + HeavyLightDecomposition hld(N); + for (int i = 0; i < N; i++) { int k; cin >> k; - for(int j = 0; j < k; j++) { + for (int j = 0; j < k; j++) { int c; cin >> c; hld.add_edge(i, c); @@ -19,7 +23,7 @@ int main() { } hld.build(); cin >> Q; - for(int i = 0; i < Q; i++) { + for (int i = 0; i < Q; i++) { int u, v; cin >> u >> v; cout << hld.lca(u, v) << "\n"; diff --git a/test/verify/aoj-grl-5-c-3.test.cpp b/test/verify/aoj-grl-5-c-3.test.cpp index 7062aeb6..63ab7adc 100644 --- a/test/verify/aoj-grl-5-c-3.test.cpp +++ b/test/verify/aoj-grl-5-c-3.test.cpp @@ -1,17 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/tree/rmq-lowest-common-ancestor.hpp" +using namespace std; + int main() { int N, Q; cin >> N; - RMQLowestCommonAncestor< int > lca(N); - for(int i = 0; i < N; i++) { + RMQLowestCommonAncestor lca(N); + for (int i = 0; i < N; i++) { int k; cin >> k; - for(int j = 0; j < k; j++) { + for (int j = 0; j < k; j++) { int c; cin >> c; lca.add_edge(i, c); @@ -19,7 +23,7 @@ int main() { } lca.build(); cin >> Q; - for(int i = 0; i < Q; i++) { + for (int i = 0; i < Q; i++) { int u, v; cin >> u >> v; cout << lca.lca(u, v) << "\n"; diff --git a/test/verify/aoj-grl-5-c-4.test.cpp b/test/verify/aoj-grl-5-c-4.test.cpp index 4af9364a..d8379f48 100644 --- a/test/verify/aoj-grl-5-c-4.test.cpp +++ b/test/verify/aoj-grl-5-c-4.test.cpp @@ -1,17 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/tree/pmormq-lowest-common-ancestor.hpp" +using namespace std; + int main() { int N, Q; cin >> N; - PMORMQLowestCommonAncestor< int > dlca(N); - for(int i = 0; i < N; i++) { + PMORMQLowestCommonAncestor dlca(N); + for (int i = 0; i < N; i++) { int k; cin >> k; - for(int j = 0; j < k; j++) { + for (int j = 0; j < k; j++) { int c; cin >> c; dlca.add_edge(i, c); @@ -19,7 +23,7 @@ int main() { } dlca.build(); cin >> Q; - for(int i = 0; i < Q; i++) { + for (int i = 0; i < Q; i++) { int u, v; cin >> u >> v; cout << dlca.lca(u, v) << "\n"; diff --git a/test/verify/aoj-grl-5-c.test.cpp b/test/verify/aoj-grl-5-c.test.cpp index 9945e0be..2588aac1 100644 --- a/test/verify/aoj-grl-5-c.test.cpp +++ b/test/verify/aoj-grl-5-c.test.cpp @@ -1,17 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/tree/doubling-lowest-common-ancestor.hpp" +using namespace std; + int main() { int N, Q; cin >> N; - DoublingLowestCommonAncestor< int > dlca(N); - for(int i = 0; i < N; i++) { + DoublingLowestCommonAncestor dlca(N); + for (int i = 0; i < N; i++) { int k; cin >> k; - for(int j = 0; j < k; j++) { + for (int j = 0; j < k; j++) { int c; cin >> c; dlca.add_edge(i, c); @@ -19,7 +23,7 @@ int main() { } dlca.build(); cin >> Q; - for(int i = 0; i < Q; i++) { + for (int i = 0; i < Q; i++) { int u, v; cin >> u >> v; cout << dlca.lca(u, v) << "\n"; diff --git a/test/verify/aoj-grl-6-a-2.test.cpp b/test/verify/aoj-grl-6-a-2.test.cpp index d5e267f1..d09f1585 100644 --- a/test/verify/aoj-grl-6-a-2.test.cpp +++ b/test/verify/aoj-grl-6-a-2.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/flow/ford-fulkerson.hpp" +using namespace std; + int main() { int V, E; scanf("%d %d", &V, &E); - FordFulkerson< int > g(V); - for(int i = 0; i < E; i++) { + FordFulkerson g(V); + for (int i = 0; i < E; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); g.add_edge(a, b, c); diff --git a/test/verify/aoj-grl-6-a-3.test.cpp b/test/verify/aoj-grl-6-a-3.test.cpp index 0038864c..dfe5cfd8 100644 --- a/test/verify/aoj-grl-6-a-3.test.cpp +++ b/test/verify/aoj-grl-6-a-3.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/flow/push-relabel.hpp" +using namespace std; + int main() { int V, E; scanf("%d %d", &V, &E); - PushRelabel< int > g(V); - for(int i = 0; i < E; i++) { + PushRelabel g(V); + for (int i = 0; i < E; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); g.add_edge(a, b, c); diff --git a/test/verify/aoj-grl-6-a-4.test.cpp b/test/verify/aoj-grl-6-a-4.test.cpp index 27e4ae53..51b4a179 100644 --- a/test/verify/aoj-grl-6-a-4.test.cpp +++ b/test/verify/aoj-grl-6-a-4.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/flow/dinic-capacity-scaling.hpp" +using namespace std; + int main() { int V, E; scanf("%d %d", &V, &E); - DinicCapacityScaling< int > g(V); - for(int i = 0; i < E; i++) { + DinicCapacityScaling g(V); + for (int i = 0; i < E; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); g.add_edge(a, b, c); diff --git a/test/verify/aoj-grl-6-a.test.cpp b/test/verify/aoj-grl-6-a.test.cpp index 24a7baf1..3175a471 100644 --- a/test/verify/aoj-grl-6-a.test.cpp +++ b/test/verify/aoj-grl-6-a.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/flow/dinic.hpp" +using namespace std; + int main() { int V, E; scanf("%d %d", &V, &E); - Dinic< int > g(V); - for(int i = 0; i < E; i++) { + Dinic g(V); + for (int i = 0; i < E; i++) { int a, b, c; scanf("%d %d %d", &a, &b, &c); g.add_edge(a, b, c); diff --git a/test/verify/aoj-grl-6-b.test.cpp b/test/verify/aoj-grl-6-b.test.cpp index ffee3433..bff6e474 100644 --- a/test/verify/aoj-grl-6-b.test.cpp +++ b/test/verify/aoj-grl-6-b.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_B +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/flow/primal-dual.hpp" +using namespace std; + int main() { int V, E, F; scanf("%d %d %d", &V, &E, &F); - PrimalDual< int, int > g(V); - for(int i = 0; i < E; i++) { + PrimalDual g(V); + for (int i = 0; i < E; i++) { int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); g.add_edge(a, b, c, d); diff --git a/test/verify/aoj-grl-7-a.test.cpp b/test/verify/aoj-grl-7-a.test.cpp index 8581cecc..635377db 100644 --- a/test/verify/aoj-grl-7-a.test.cpp +++ b/test/verify/aoj-grl-7-a.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/flow/bipartite-matching.hpp" +using namespace std; + int main() { int X, Y, E; scanf("%d %d %d", &X, &Y, &E); BipartiteMatching bm(X + Y); - for(int i = 0; i < E; i++) { + for (int i = 0; i < E; i++) { int a, b; scanf("%d %d", &a, &b); bm.add_edge(a, X + b); diff --git a/test/verify/aoj-itp1-3-d.test.cpp b/test/verify/aoj-itp1-3-d.test.cpp index 13673a85..4122c4bf 100644 --- a/test/verify/aoj-itp1-3-d.test.cpp +++ b/test/verify/aoj-itp1-3-d.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_3_D +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/number-theory/divisor.hpp" +using namespace std; + int main() { int A, B, C; cin >> A >> B >> C; int ret = 0; - for(auto &p : divisor(C)) { + for (auto& p : divisor(C)) { ret += A <= p and p <= B; } cout << ret << "\n"; diff --git a/test/verify/aoj-ntl-1-a.test.cpp b/test/verify/aoj-ntl-1-a.test.cpp index 515f567f..c5bed3ad 100644 --- a/test/verify/aoj-ntl-1-a.test.cpp +++ b/test/verify/aoj-ntl-1-a.test.cpp @@ -1,15 +1,19 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/number-theory/prime-factor.hpp" +using namespace std; + int main() { int N; cin >> N; cout << N << ":"; - for(auto p : prime_factor(N)) { - while(p.second--) cout << " " << p.first; + for (auto p : prime_factor(N)) { + while (p.second--) cout << " " << p.first; } cout << endl; } diff --git a/test/verify/aoj-ntl-1-b.test.cpp b/test/verify/aoj-ntl-1-b.test.cpp index 830c5fda..01c82d7e 100644 --- a/test/verify/aoj-ntl-1-b.test.cpp +++ b/test/verify/aoj-ntl-1-b.test.cpp @@ -1,11 +1,15 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/combinatorics/mod-pow.hpp" +using namespace std; + int main() { - int64 M, N; + long long M, N; cin >> M >> N; - cout << mod_pow(M, N, (int64)(1e9 + 7)) << endl; + cout << mod_pow(M, N, 1000000007LL) << endl; } diff --git a/test/verify/aoj-ntl-1-d.test.cpp b/test/verify/aoj-ntl-1-d.test.cpp index a352cb6e..e6545a29 100644 --- a/test/verify/aoj-ntl-1-d.test.cpp +++ b/test/verify/aoj-ntl-1-d.test.cpp @@ -1,11 +1,15 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_D +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/number-theory/euler-phi.hpp" +using namespace std; + int main() { int N; cin >> N; - cout << euler_phi< int64_t >(N) << endl; + cout << euler_phi(N) << endl; } diff --git a/test/verify/aoj-ntl-1-e.test.cpp b/test/verify/aoj-ntl-1-e.test.cpp index 5f13e04d..cf910916 100644 --- a/test/verify/aoj-ntl-1-e.test.cpp +++ b/test/verify/aoj-ntl-1-e.test.cpp @@ -1,9 +1,13 @@ +// clang-format off // competitive-verifier: PROBLEM http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_E +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/number-theory/extgcd.hpp" +using namespace std; + int main() { int a, b, x, y; cin >> a >> b; diff --git a/test/verify/yosupo-cartesian-tree.test.cpp b/test/verify/yosupo-cartesian-tree.test.cpp index d16313a4..5ef95c39 100644 --- a/test/verify/yosupo-cartesian-tree.test.cpp +++ b/test/verify/yosupo-cartesian-tree.test.cpp @@ -1,18 +1,25 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/cartesian_tree +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../graph/others/cartesian-tree.hpp" +using namespace std; + int main() { int N; cin >> N; - vector< int > A(N); - for(auto &a : A) cin >> a; + vector A(N); + for (auto& a : A) cin >> a; auto p = cartesian_tree(A); - for(int i = 0; i < N; i++) { - if(p[i] >= 0) cout << p[i] << " "; - else cout << i << " "; + for (int i = 0; i < N; i++) { + if (p[i] >= 0) + cout << p[i] << " "; + else + cout << i << " "; } cout << "\n"; } diff --git a/test/verify/yosupo-enumerate-primes.test.cpp b/test/verify/yosupo-enumerate-primes.test.cpp index 28b72db9..3e1419ae 100644 --- a/test/verify/yosupo-enumerate-primes.test.cpp +++ b/test/verify/yosupo-enumerate-primes.test.cpp @@ -1,17 +1,26 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/enumerate_primes +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../math/number-theory/enumerate-primes.hpp" +using namespace std; + int main() { int N, A, B; cin >> N >> A >> B; auto d = enumerate_primes(N); - vector< int > ans; - for(int i = B; i < d.size(); i += A) { + vector ans; + for (int i = B; i < static_cast(d.size()); i += A) { ans.emplace_back(d[i]); } cout << d.size() << " " << ans.size() << "\n"; - cout << ans << "\n"; + for (int i = 0; i < static_cast(ans.size()); i++) { + if (i > 0) cout << " "; + cout << ans[i]; + } + cout << "\n"; } diff --git a/test/verify/yosupo-factorize.test.cpp b/test/verify/yosupo-factorize.test.cpp index 663a679a..747fcc6d 100644 --- a/test/verify/yosupo-factorize.test.cpp +++ b/test/verify/yosupo-factorize.test.cpp @@ -1,18 +1,24 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/factorize +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../math/number-theory/fast-prime-factorization.hpp" +using namespace std; + int main() { int Q; cin >> Q; - while(Q--) { - int64 X; + while (Q--) { + long long X; cin >> X; auto ret = FastPrimeFactorization::prime_factor(X); - sort(begin(ret), end(ret)); - cout << ret.size() << " "; - cout << ret << "\n"; + sort(ret.begin(), ret.end()); + cout << ret.size(); + for (auto factor : ret) cout << " " << factor; + cout << "\n"; } } diff --git a/test/verify/yosupo-lca-2.test.cpp b/test/verify/yosupo-lca-2.test.cpp index b21e7b78..6e21215a 100644 --- a/test/verify/yosupo-lca-2.test.cpp +++ b/test/verify/yosupo-lca-2.test.cpp @@ -1,27 +1,28 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/lca +// clang-format on -#include "../../template/template.hpp" +#include -#include "../../graph/graph-template.hpp" #include "../../graph/tree/rmq-lowest-common-ancestor.hpp" - -#include "../../other/scanner.hpp" #include "../../other/printer.hpp" +#include "../../other/scanner.hpp" +using namespace std; int main() { Scanner in(stdin); Printer out(stdout); int N, Q; in.read(N, Q); - RMQLowestCommonAncestor< int > g(N); - for(int i = 1; i < N; i++) { + RMQLowestCommonAncestor g(N); + for (int i = 1; i < N; i++) { int x; in.read(x); g.add_directed_edge(x, i); } g.build(); - for(int i = 0; i < Q; i++) { + for (int i = 0; i < Q; i++) { int u, v; in.read(u, v); out.writeln(g.lca(u, v)); diff --git a/test/verify/yosupo-lca-3.test.cpp b/test/verify/yosupo-lca-3.test.cpp index 89cf34ca..b9d79788 100644 --- a/test/verify/yosupo-lca-3.test.cpp +++ b/test/verify/yosupo-lca-3.test.cpp @@ -1,26 +1,28 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/lca +// clang-format on -#include "../../template/template.hpp" +#include -#include "../../graph/graph-template.hpp" #include "../../graph/tree/doubling-lowest-common-ancestor.hpp" - -#include "../../other/scanner.hpp" #include "../../other/printer.hpp" +#include "../../other/scanner.hpp" + +using namespace std; int main() { Scanner in(stdin); Printer out(stdout); int N, Q; in.read(N, Q); - DoublingLowestCommonAncestor< int > g(N); - for(int i = 1; i < N; i++) { + DoublingLowestCommonAncestor g(N); + for (int i = 1; i < N; i++) { int x; in.read(x); g.add_directed_edge(x, i); } g.build(); - for(int i = 0; i < Q; i++) { + for (int i = 0; i < Q; i++) { int u, v; in.read(u, v); out.writeln(g.lca(u, v)); diff --git a/test/verify/yosupo-lca-4.test.cpp b/test/verify/yosupo-lca-4.test.cpp index e54cc9b0..042a6f5c 100644 --- a/test/verify/yosupo-lca-4.test.cpp +++ b/test/verify/yosupo-lca-4.test.cpp @@ -1,25 +1,30 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/lca +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../graph/tree/offline-lca.hpp" - -#include "../../other/scanner.hpp" #include "../../other/printer.hpp" +#include "../../other/scanner.hpp" + +using namespace std; int main() { Scanner in(stdin); Printer out(stdout); int N, Q; in.read(N, Q); - Graph< int > g(N); - for(int i = 1; i < N; i++) { + Graph g(N); + for (int i = 1; i < N; i++) { int x; in.read(x); g.add_directed_edge(x, i); } - vector< pair< int, int > > qs(Q); - for(auto&[l, r]: qs) in.read(l, r); + vector> qs(Q); + for (auto& [l, r] : qs) in.read(l, r); auto ans = offline_lca(g, qs); - for(auto &p: ans) out.writeln(p); + for (auto& p : ans) out.writeln(p); } diff --git a/test/verify/yosupo-lca.test.cpp b/test/verify/yosupo-lca.test.cpp index f66068ff..3853abb2 100644 --- a/test/verify/yosupo-lca.test.cpp +++ b/test/verify/yosupo-lca.test.cpp @@ -1,27 +1,28 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/lca +// clang-format on -#include "../../template/template.hpp" +#include -#include "../../graph/graph-template.hpp" #include "../../graph/tree/pmormq-lowest-common-ancestor.hpp" - -#include "../../other/scanner.hpp" #include "../../other/printer.hpp" +#include "../../other/scanner.hpp" +using namespace std; int main() { Scanner in(stdin); Printer out(stdout); int N, Q; in.read(N, Q); - PMORMQLowestCommonAncestor< int > g(N); - for(int i = 1; i < N; i++) { + PMORMQLowestCommonAncestor g(N); + for (int i = 1; i < N; i++) { int x; in.read(x); g.add_directed_edge(x, i); } g.build(); - for(int i = 0; i < Q; i++) { + for (int i = 0; i < Q; i++) { int u, v; in.read(u, v); out.writeln(g.lca(u, v)); diff --git a/test/verify/yosupo-persistent-unionfind.test.cpp b/test/verify/yosupo-persistent-unionfind.test.cpp index aaf59297..b316fc2a 100644 --- a/test/verify/yosupo-persistent-unionfind.test.cpp +++ b/test/verify/yosupo-persistent-unionfind.test.cpp @@ -1,19 +1,24 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/persistent_unionfind +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../structure/union-find/persistent-union-find.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - vector< PersistentUnionFind > uf(Q + 1); + vector uf(Q + 1); uf[0] = PersistentUnionFind(N); - for(int i = 1; i <= Q; i++) { + for (int i = 1; i <= Q; i++) { int t, k, u, v; cin >> t >> k >> u >> v; ++k; - if(t == 0) { + if (t == 0) { uf[i] = uf[k]; uf[i].unite(u, v); } else { diff --git a/test/verify/yosupo-primality-test.test.cpp b/test/verify/yosupo-primality-test.test.cpp index 28c12405..db869efb 100644 --- a/test/verify/yosupo-primality-test.test.cpp +++ b/test/verify/yosupo-primality-test.test.cpp @@ -1,14 +1,18 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/primality_test +// clang-format on -#include "../../template/template.hpp" +#include #include "../../math/number-theory/fast-prime-factorization.hpp" +using namespace std; + int main() { int Q; cin >> Q; - while(Q--) { - int64 N; + while (Q--) { + long long N; cin >> N; cout << (FastPrimeFactorization::is_prime(N) ? "Yes" : "No") << "\n"; } diff --git a/test/verify/yosupo-range-kth-smallest-2.test.cpp b/test/verify/yosupo-range-kth-smallest-2.test.cpp index 96e61d79..9bb108e6 100644 --- a/test/verify/yosupo-range-kth-smallest-2.test.cpp +++ b/test/verify/yosupo-range-kth-smallest-2.test.cpp @@ -1,17 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/range_kth_smallest +// clang-format on -#include "../../template/template.hpp" +#include +#include -#include "../../structure/wavelet/succinct-indexable-dictionary.hpp" #include "../../structure/wavelet/wavelet-tree.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - vector< int > A(N); - cin >> A; - CompressedWaveletTree< int, 18 > mat(A); - for(int i = 0; i < Q; i++) { + vector A(N); + for (int& a : A) cin >> a; + CompressedWaveletTree mat(A); + for (int i = 0; i < Q; i++) { int a, b, c; cin >> a >> b >> c; cout << mat.kth_smallest(a, b, c) << "\n"; diff --git a/test/verify/yosupo-range-kth-smallest-3.test.cpp b/test/verify/yosupo-range-kth-smallest-3.test.cpp index 2fe01c3a..384c58ac 100644 --- a/test/verify/yosupo-range-kth-smallest-3.test.cpp +++ b/test/verify/yosupo-range-kth-smallest-3.test.cpp @@ -1,48 +1,54 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/range_kth_smallest +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../structure/segment-tree/persistent-segment-tree.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - vector< int > A(N); - for(auto& a : A) cin >> a; + vector A(N); + for (auto& a : A) cin >> a; auto xs = A; sort(xs.begin(), xs.end()); xs.erase(unique(xs.begin(), xs.end()), xs.end()); - auto f = [](int64 a, int64 b) { return a + b; }; + auto f = [](long long a, long long b) { return a + b; }; auto e = []() { return 0ll; }; auto monoid = LambdaMonoid(f, e); - PersistentSegmentTree segCnt(monoid, N); - vector< decltype(segCnt)::NP > cntNP(xs.size() + 1); - cntNP[0] = segCnt.build(vector< int64 >(N, 0ll)); + PersistentSegmentTree segCnt(monoid, N); + vector cntNP(xs.size() + 1); + cntNP[0] = segCnt.build(vector(N, 0ll)); - vector< vector< int > > upd(xs.size());; - for(int i = 0; i < N; i++) { + vector> upd(xs.size()); + for (int i = 0; i < N; i++) { A[i] = lower_bound(xs.begin(), xs.end(), A[i]) - xs.begin(); upd[A[i]].emplace_back(i); } - for(int i = 0; i < xs.size(); i++) { + for (int i = 0; i < static_cast(xs.size()); i++) { auto cntNow = cntNP[i]; - for(auto& j : upd[i]) { + for (auto& j : upd[i]) { cntNow = segCnt.set(cntNow, j, 1); } cntNP[i + 1] = cntNow; } - while(Q--) { + while (Q--) { int l, r, k; cin >> l >> r >> k; - int ok = -1, ng = (int) xs.size() - 1; - auto check = [&](int p) { - return segCnt.prod(cntNP[p + 1], l, r) <= k; - }; - while(ng - ok > 1) { + int ok = -1, ng = static_cast(xs.size()) - 1; + auto check = [&](int p) { return segCnt.prod(cntNP[p + 1], l, r) <= k; }; + while (ng - ok > 1) { int mid = (ok + ng) / 2; - if(check(mid)) ok = mid; - else ng = mid; + if (check(mid)) + ok = mid; + else + ng = mid; } cout << xs[ok + 1] << "\n"; } diff --git a/test/verify/yosupo-range-kth-smallest.test.cpp b/test/verify/yosupo-range-kth-smallest.test.cpp index ab033dda..8e24c677 100644 --- a/test/verify/yosupo-range-kth-smallest.test.cpp +++ b/test/verify/yosupo-range-kth-smallest.test.cpp @@ -1,16 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/range_kth_smallest +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../structure/wavelet/wavelet-matrix.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - vector< int > A(N); - cin >> A; - CompressedWaveletMatrix< int, 18 > mat(A); - for(int i = 0; i < Q; i++) { + vector A(N); + for (int& a : A) cin >> a; + CompressedWaveletMatrix mat(A); + for (int i = 0; i < Q; i++) { int a, b, c; cin >> a >> b >> c; cout << mat.kth_smallest(a, b, c) << "\n"; diff --git a/test/verify/yosupo-scc.test.cpp b/test/verify/yosupo-scc.test.cpp index 32b77ae2..3a0ff725 100644 --- a/test/verify/yosupo-scc.test.cpp +++ b/test/verify/yosupo-scc.test.cpp @@ -1,9 +1,13 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/scc +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/connected-components/strongly-connected-components.hpp" +using namespace std; + int main() { int N, M; cin >> N >> M; @@ -11,7 +15,9 @@ int main() { g.read(M, 0, false, true); g.build(); cout << g.group.size() << "\n"; - for(auto &p : g.group) { - cout << p.size() << " " << p << "\n"; + for (auto& p : g.group) { + cout << p.size(); + for (int v : p) cout << " " << v; + cout << "\n"; } } diff --git a/test/verify/yosupo-set-xor-min.test.cpp b/test/verify/yosupo-set-xor-min.test.cpp index e296ee96..011b768b 100644 --- a/test/verify/yosupo-set-xor-min.test.cpp +++ b/test/verify/yosupo-set-xor-min.test.cpp @@ -1,20 +1,24 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/set_xor_min +// clang-format on -#include "../../template/template.hpp" +#include #include "../../structure/trie/binary-trie.hpp" +using namespace std; + int main() { int Q; cin >> Q; - BinaryTrie< int, 29 > trie; - for(int i = 0; i < Q; i++) { + BinaryTrie trie; + for (int i = 0; i < Q; i++) { int t, x; cin >> t >> x; - if(t == 0) { - if(trie.count(x) == 0) trie.add(x); - } else if(t == 1) { - if(trie.count(x) != 0) trie.erase(x); + if (t == 0) { + if (trie.count(x) == 0) trie.add(x); + } else if (t == 1) { + if (trie.count(x) != 0) trie.erase(x); } else { cout << trie.min_element(x).first << "\n"; } diff --git a/test/verify/yosupo-static-range-sum.test.cpp b/test/verify/yosupo-static-range-sum.test.cpp index 07aac288..a9dc010c 100644 --- a/test/verify/yosupo-static-range-sum.test.cpp +++ b/test/verify/yosupo-static-range-sum.test.cpp @@ -1,20 +1,24 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/static_range_sum +// clang-format on -#include "../../template/template.hpp" +#include #include "../../dp/cumulative-sum.hpp" +using namespace std; + int main() { int n, q; cin >> n >> q; - CumulativeSum< int64 > cs(n); - for(int i = 0; i < n; i++) { + CumulativeSum cs(n); + for (int i = 0; i < n; i++) { int x; cin >> x; cs.add(i, x); } cs.build(); - for(int i = 0; i < q; i++) { + for (int i = 0; i < q; i++) { int l, r; cin >> l >> r; cout << cs.fold(l, r) << "\n"; diff --git a/test/verify/yosupo-staticrmq-2.test.cpp b/test/verify/yosupo-staticrmq-2.test.cpp index 01569a88..929b5813 100644 --- a/test/verify/yosupo-staticrmq-2.test.cpp +++ b/test/verify/yosupo-staticrmq-2.test.cpp @@ -1,17 +1,23 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/staticrmq +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../structure/others/disjoint-sparse-table.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - vector< int > A(N); - cin >> A; + vector A(N); + for (int& a : A) cin >> a; auto f = [](int a, int b) { return min(a, b); }; auto st = get_disjoint_sparse_table(A, f); - while(Q--) { + while (Q--) { int l, r; cin >> l >> r; cout << st.fold(l, r) << "\n"; diff --git a/test/verify/yosupo-staticrmq-3.test.cpp b/test/verify/yosupo-staticrmq-3.test.cpp index 01df7ff2..246fa65e 100644 --- a/test/verify/yosupo-staticrmq-3.test.cpp +++ b/test/verify/yosupo-staticrmq-3.test.cpp @@ -1,23 +1,27 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/staticrmq +// clang-format on -#include "../../template/template.hpp" - -#include "../../other/vector-pool.hpp" +#include +#include +#include +#include #include "../../structure/bbst/red-black-tree.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - vector< int > A(N); - cin >> A; + vector A(N); + for (int& a : A) cin >> a; auto f = [](int a, int b) { return min(a, b); }; - RedBlackTree< int, decltype(f) > rbt(2 * N, f, inf); + RedBlackTree rbt(2 * N, f, numeric_limits::max()); auto root = rbt.build(A); - while(Q--) { + while (Q--) { int l, r; cin >> l >> r; cout << rbt.query(root, l, r) << "\n"; } } - diff --git a/test/verify/yosupo-staticrmq-4.test.cpp b/test/verify/yosupo-staticrmq-4.test.cpp index 2ec6ddd9..5f6ca0dd 100644 --- a/test/verify/yosupo-staticrmq-4.test.cpp +++ b/test/verify/yosupo-staticrmq-4.test.cpp @@ -1,28 +1,32 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/staticrmq +// clang-format on -#include "../../template/template.hpp" +#include +#include -#include "../../graph/graph-template.hpp" -#include "../../graph/tree/pmormq-lowest-common-ancestor.hpp" #include "../../graph/others/cartesian-tree.hpp" +#include "../../graph/tree/pmormq-lowest-common-ancestor.hpp" + +using namespace std; int main() { int N, Q; cin >> N >> Q; - vector< int > A(N); - cin >> A; + vector A(N); + for (int& a : A) cin >> a; auto t = cartesian_tree(A); - PMORMQLowestCommonAncestor< int > g(N); + PMORMQLowestCommonAncestor g(N); int root = -1; - for(int i = 0; i < N; i++) { - if(t[i] == -1) { + for (int i = 0; i < N; i++) { + if (t[i] == -1) { root = i; continue; } g.add_directed_edge(t[i], i); } g.build(root); - while(Q--) { + while (Q--) { int l, r; cin >> l >> r; cout << A[g.lca(l, r - 1)] << "\n"; diff --git a/test/verify/yosupo-staticrmq-5.test.cpp b/test/verify/yosupo-staticrmq-5.test.cpp index 49c4f84d..179b7505 100644 --- a/test/verify/yosupo-staticrmq-5.test.cpp +++ b/test/verify/yosupo-staticrmq-5.test.cpp @@ -1,22 +1,26 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/staticrmq +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include "../../other/printer.hpp" +#include "../../other/scanner.hpp" #include "../../structure/others/linear-rmq.hpp" -#include "../../other/scanner.hpp" -#include "../../other/printer.hpp" +using namespace std; int main() { Scanner in(stdin); Printer out(stdout); int N, Q; in.read(N, Q); - vector< int > A(N); + vector A(N); in.read(A); auto f = [&](int a, int b) { return A[a] < A[b]; }; auto seg = get_linear_rmq(N, f); - while(Q--) { + while (Q--) { int l, r; in.read(l, r); out.writeln(A[seg.fold(l, r)]); diff --git a/test/verify/yosupo-staticrmq-6.test.cpp b/test/verify/yosupo-staticrmq-6.test.cpp index 814ba717..af0787a5 100644 --- a/test/verify/yosupo-staticrmq-6.test.cpp +++ b/test/verify/yosupo-staticrmq-6.test.cpp @@ -1,22 +1,26 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/staticrmq +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../other/offline-rmq.hpp" - -#include "../../other/scanner.hpp" #include "../../other/printer.hpp" +#include "../../other/scanner.hpp" +using namespace std; int main() { Scanner in(stdin); Printer out(stdout); int N, Q; in.read(N, Q); - vector< int > A(N); + vector A(N); in.read(A); - vector< pair< int, int > > qs(Q); - for(auto&[l, r]: qs) in.read(l, r); + vector> qs(Q); + for (auto& [l, r] : qs) in.read(l, r); auto ans = offline_rmq(qs, [&](int a, int b) { return A[a] < A[b]; }); - for(int i = 0; i < Q; i++) out.writeln(A[ans[i]]); + for (int i = 0; i < Q; i++) out.writeln(A[ans[i]]); } diff --git a/test/verify/yosupo-staticrmq.test.cpp b/test/verify/yosupo-staticrmq.test.cpp index ae770a98..5be6ddd4 100644 --- a/test/verify/yosupo-staticrmq.test.cpp +++ b/test/verify/yosupo-staticrmq.test.cpp @@ -1,16 +1,22 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/staticrmq +// clang-format on -#include "../../template/template.hpp" +#include +#include +#include #include "../../structure/others/sparse-table.hpp" +using namespace std; + int main() { int N, Q; cin >> N >> Q; - vector< int > A(N); - cin >> A; + vector A(N); + for (int& a : A) cin >> a; auto st = get_sparse_table(A, [](int a, int b) { return min(a, b); }); - while(Q--) { + while (Q--) { int l, r; cin >> l >> r; cout << st.fold(l, r) << "\n"; diff --git a/test/verify/yosupo-suffixarray.test.cpp b/test/verify/yosupo-suffixarray.test.cpp index 999c1474..78f0cb90 100644 --- a/test/verify/yosupo-suffixarray.test.cpp +++ b/test/verify/yosupo-suffixarray.test.cpp @@ -1,13 +1,22 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/suffixarray +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../string/suffix-array.hpp" +using namespace std; + int main() { string s; cin >> s; auto sa = SuffixArray(s); sa.erase(sa.begin()); - cout << sa << "\n"; + for (int i = 0; i < static_cast(sa.size()); i++) { + if (i > 0) cout << " "; + cout << sa[i]; + } + cout << "\n"; } diff --git a/test/verify/yosupo-tree-diameter.test.cpp b/test/verify/yosupo-tree-diameter.test.cpp index c15fae5c..7bedac04 100644 --- a/test/verify/yosupo-tree-diameter.test.cpp +++ b/test/verify/yosupo-tree-diameter.test.cpp @@ -1,15 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/tree_diameter +// clang-format on -#include "../../template/template.hpp" +#include #include "../../graph/tree/tree-diameter.hpp" +using namespace std; + int main() { int N; cin >> N; - TreeDiameter< int64_t > g(N); + TreeDiameter g(N); g.read(N - 1, 0, true); cout << g.build() << " "; cout << g.path.size() + 1 << "\n"; - cout << g.path[0].from << " " << g.path << "\n"; + cout << g.path[0].from; + for (auto& edge : g.path) cout << " " << edge.to; + cout << "\n"; } diff --git a/test/verify/yosupo-zalgorithm.test.cpp b/test/verify/yosupo-zalgorithm.test.cpp index 84b15301..fd8d3371 100644 --- a/test/verify/yosupo-zalgorithm.test.cpp +++ b/test/verify/yosupo-zalgorithm.test.cpp @@ -1,11 +1,21 @@ +// clang-format off // competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/zalgorithm +// clang-format on -#include "../../template/template.hpp" +#include +#include #include "../../string/z-algorithm.hpp" +using namespace std; + int main() { string s; cin >> s; - cout << ZAlgorithm(s).get() << "\n"; + auto z = ZAlgorithm(s).get(); + for (int i = 0; i < static_cast(z.size()); i++) { + if (i > 0) cout << " "; + cout << z[i]; + } + cout << "\n"; }