Skip to content

Commit

Permalink
Merge pull request #344 from hitonanode/clang-format-19
Browse files Browse the repository at this point in the history
clang-format-19 対応
  • Loading branch information
hitonanode authored Sep 22, 2024
2 parents b1ad247 + a8c8b58 commit d4836fa
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 292 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ on:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# https://apt.llvm.org/
- name: Install clang-format-16
- name: Install clang-format-19
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main'
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository 'deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main'
sudo add-apt-repository 'deb-src http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main'
sudo apt-get update
sudo apt-get install -y clang-format-16
sudo apt-get install -y clang-format-19
- name: Check formatting
run: find ./ -name "*.hpp" -o -name "*.cpp" -not -iwholename ".verify-helper*" | xargs clang-format-16 --dry-run --Werror -style=file
run: find . -name "*.hpp" -o -name "*.cpp" -not -iwholename "*/.verify-helper/*" | xargs clang-format-19 --dry-run --Werror -style=file
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: format

format:
find ./ -name "*.hpp" -o -name "*.cpp" -not -iwholename ".verify-helper*" | xargs clang-format --Werror -i -style=file
find . -name "*.hpp" -o -name "*.cpp" -not -iwholename "*/.verify-helper/*" | xargs clang-format --Werror -i -style=file
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Except such snippets, the programs written by the owner of the repo is under the

## Formatting

`clang-format-16` is used to lint `.cpp` / `.hpp` files. Default configuration file is `.clang-format`. See [formatter.yml](.github/workflows/formatter.yml) for detail.
`clang-format-19` is used to lint `.cpp` / `.hpp` files. Default configuration file is `.clang-format`. See [formatter.yml](.github/workflows/formatter.yml) for detail.
4 changes: 1 addition & 3 deletions convolution/fft_double.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
#include <utility>
#include <vector>

// CUT begin
// Convolution by FFT (Fast Fourier Transform)
// Algorithm based on http://kirika-comp.hatenablog.com/entry/2018/03/12/210446
// Verified: ATC001C (168 ms) https://atcoder.jp/contests/atc001/submissions/9243440
using cmplx = std::complex<double>;
void fft(int N, std::vector<cmplx> &a, double dir) {
int i = 0;
for (int j = 1; j < N - 1; j++) {
for (int k = N >> 1; k > (i ^= k); k >>= 1)
;
for (int k = N >> 1; k > (i ^= k); k >>= 1) {}
if (j < i) std::swap(a[i], a[j]);
}

Expand Down
11 changes: 4 additions & 7 deletions convolution/hadamard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <cassert>
#include <vector>

// CUT begin
// Fast Walsh-Hadamard transform and its abstraction
// Tutorials: <https://codeforces.com/blog/entry/71899>
// <https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it>
Expand All @@ -11,7 +10,7 @@ template <typename T, typename F> void abstract_fwht(std::vector<T> &seq, F f) {
assert(__builtin_popcount(n) == 1);
for (int w = 1; w < n; w *= 2) {
for (int i = 0; i < n; i += w * 2) {
for (int j = 0; j < w; j++) { f(seq[i + j], seq[i + j + w]); }
for (int j = 0; j < w; j++) f(seq.at(i + j), seq.at(i + j + w));
}
}
}
Expand All @@ -26,7 +25,7 @@ std::vector<T> bitwise_conv(std::vector<T> x, std::vector<T> y, F1 f, F2 finv) {
} else {
abstract_fwht(x, f), abstract_fwht(y, f);
}
for (size_t i = 0; i < x.size(); i++) { x[i] *= y[i]; }
for (int i = 0; i < (int)x.size(); i++) x.at(i) *= y.at(i);
abstract_fwht(x, finv);
return x;
}
Expand All @@ -50,13 +49,11 @@ template <typename T> std::vector<T> xorconv(std::vector<T> x, std::vector<T> y)
// bitwise AND conolution
// ret[i] = \sum_{(j & k) == i} x[j] * y[k]
template <typename T> std::vector<T> andconv(std::vector<T> x, std::vector<T> y) {
return bitwise_conv(
x, y, [](T &lo, T &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });
return bitwise_conv(x, y, [](T &lo, T &hi) { lo += hi; }, [](T &lo, T &hi) { lo -= hi; });
}

// bitwise OR convolution
// ret[i] = \sum_{(j | k) == i} x[j] * y[k]
template <typename T> std::vector<T> orconv(std::vector<T> x, std::vector<T> y) {
return bitwise_conv(
x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });
return bitwise_conv(x, y, [](T &lo, T &hi) { hi += lo; }, [](T &lo, T &hi) { hi -= lo; });
}
268 changes: 0 additions & 268 deletions data_structure/rbst_fast.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion flow/networksimplex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ template <typename Capacity = long long, typename Weight = long long> struct mcf
int E;
std::vector<std::vector<int>> in_eids, out_eids;
std::vector<std::pair<int, int>> arcs;
Digraph(int V = 0) : V(V), E(0), in_eids(V), out_eids(V){};
Digraph(int V = 0) : V(V), E(0), in_eids(V), out_eids(V) {};
int add_edge(int s, int t) {
assert(0 <= s and s < V);
assert(0 <= t and t < V);
Expand Down
5 changes: 2 additions & 3 deletions multithread/multithread_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using namespace std;
using pint = pair<int, int>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define IFOR(i, begin, end) for (int i = (end) - 1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
Expand All @@ -21,8 +21,7 @@ vector<string> ret;
mutex mtx;
vector<int> done;

void solve(int tc) { /* tc個目のテストケースを処理する関数 */
}
void solve(int tc) { /* tc個目のテストケースを処理する関数 */ }

void run() {
/* 未完了で最も番号が若いテストケースを処理 */
Expand Down
Loading

0 comments on commit d4836fa

Please sign in to comment.