Skip to content

Commit

Permalink
ci: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiphereth-A committed Apr 24, 2024
1 parent bde9f78 commit e95cc95
Show file tree
Hide file tree
Showing 18 changed files with 92 additions and 43 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches:
- master
paths:
- '**.hpp'
- '**.cpp'
- '**.py'
- '**.yml'
pull_request:
branches: [ "master" ]
branches:
- master
schedule:
- cron: '28 14 * * 6'
- cron: '0 0 * * 6'

concurrency:
group: ${{ github.head_ref || 'x' }}-${{ github.workflow }}-${{ github.ref }}-codeql
cancel-in-progress: true

jobs:
analyze:
Expand All @@ -44,8 +55,8 @@ jobs:
fail-fast: false
matrix:
include:
# - language: c-cpp
# build-mode: autobuild
- language: c-cpp
build-mode: manual
- language: python
build-mode: none
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
Expand Down Expand Up @@ -73,6 +84,10 @@ jobs:
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

- name: Autobuild
if: matrix.build-mode == 'autobuild'
uses: github/codeql-action/autobuild@v3

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
Expand All @@ -81,12 +96,7 @@ jobs:
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
make -j 64 all
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ on:
push:
branches:
- master
paths:
- '**.hpp'
- '**.cpp'
- '**.tex'
- '**.yml'
pull_request:
branches:
- master
workflow_dispatch:
workflow_dispatch:

concurrency:
group: ${{ github.head_ref || 'x' }}-${{ github.workflow }}-${{ github.ref }}-pdf
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
push:
branches:
- master
paths:
- '**.hpp'
- '**.cpp'
- '**.yml'
pull_request:
branches:
- master
Expand Down
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# AIGC

# Compiler
CXX := g++-12
# Compiler flags
CXXFLAGS := -std=gnu++20 -O2 -Wall -Wextra

# Directories
SRCDIRS := src/test_tinplate src/test_cpverifier
# Source files
SOURCES := $(foreach dir,$(SRCDIRS),$(wildcard $(dir)/*/*.cpp))
# Object files
OBJECTS := $(SOURCES:.cpp=.o)

# Rule to compile each source file into object files
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@

# Phony targets
.PHONY: all clean

# Target to build all
all: $(OBJECTS)

# Target to clean the generated files
clean:
rm -rf $(OUTDIR) $(OBJECTS)
2 changes: 1 addition & 1 deletion src/code/conv/conv_minplus_ca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ constexpr vec<T> conv_minplus_ca(vec<T> const& a, vec<T> const& b) {
[&](u32 k, u32 j1, u32 j2) -> bool {
i32 i1 = (i32)k - (i32)j1, i2 = (i32)k - (i32)j2;
if (i2 < 0) return 1;
if (i1 >= n) return 0;
if (i1 >= (i32)n) return 0;
return a[i1] + b[j1] < a[i2] + b[j2];
});
vec<T> c(n + m - 1);
Expand Down
5 changes: 3 additions & 2 deletions src/code/edh/base64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class Base64 {

public:
static constexpr strn encode(vec<usz> const &a) {
usz x = *std::ranges::max_element(a), y = *std::ranges::min_element(a);
usz N = a.size(), B = std::max(usz(6), (sizeof(usz) * 8 - (usz)(y < 0 ? 0 : std::countl_zero(x))));
usz x = *std::ranges::max_element(a);
std::bit_width(x);
usz N = a.size(), B = std::max(6_uz, (usz)std::bit_width(x));
strn S((B * N + 11) / 6, 0);
S[0] = (char)B;
for (usz i = 0; i < N; ++i)
Expand Down
4 changes: 2 additions & 2 deletions src/code/game/sudoku.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ constexpr v3ecu sudoku_solver(vvecu const &data, bool get_all_solution = false)
}
if (!not_filled) return {data};
v3ecu ans;
util::DLX(g, get_all_solution).dance([&](vec<usz> const &res) -> void {
util::DLX(g, get_all_solution).dance([&](vecu const &res) -> void {
vvecu dt = data;
for (usz _ : res) dt[(_ - 1) % n4 / n2][(_ - 1) % n2] = u32((_ - 1) / n4 + 1);
for (u32 _ : res) dt[(_ - 1) % n4 / n2][(_ - 1) % n2] = (_ - 1) / n4 + 1;
ans.push_back(dt);
});
return ans;
Expand Down
7 changes: 3 additions & 4 deletions src/code/graph/amat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ struct amat {
}

constexpr void set_arc(u32 u, u32 v, T const& w) {
if (g[u][v] >= g.size()) {
++cnt_arc;
if constexpr (with_deg) ++deg_in[v], ++deg_out[u];
}
if (g[u][v] == w) return;
++cnt_arc;
g[u][v] = w;
if constexpr (with_deg) ++deg_in[v], ++deg_out[u];
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/code/graph/steiner_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class steiner_tree {
}
}
};
for (u32 s = 1; s < (1 << a.size()); ++s) {
for (u32 s = 1; s < (1_u32 << a.size()); ++s) {
for (u32 i = 0; i < e.g.size(); ++i) {
for (u32 ss = s & (s - 1); ss; ss = s & (ss - 1))
dp[i][s] = std::min(dp[i][s], dp[i][ss] + dp[i][s ^ ss]);
Expand Down
2 changes: 1 addition & 1 deletion src/code/math/mint_d31.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class mint_d31 : public mint<mint_d31<ID>, u32> {
static constexpr void set_mod(u32 m) {
assert(!(m == 1 || m >> 31));
for (MOD = MOD_ODD = m, OFFSET = 0; (MOD_ODD & 1) == 0; ++OFFSET, MOD_ODD /= 2);
MASK = (1 << OFFSET) - 1;
MASK = (1_u32 << OFFSET) - 1_u32;
u32 t = 2, iv = MOD_ODD * (t - MOD_ODD * MOD_ODD);
iv *= t - MOD_ODD * iv, iv *= t - MOD_ODD * iv;
R = iv * (MOD_ODD * iv - t);
Expand Down
2 changes: 1 addition & 1 deletion src/code/math/mint_s63.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class mint_s63 : public mint<mint_s63<MOD>, u64> {
using raw_t = typename base::raw_type;
using sraw_t = typename base::sraw_type;
template <int_c T>
static constexpr raw_t mod_(T v) { return redc_mul(norm(v % (std::conditional_t<sint_c<T>, i64, u64>)mod_()), R2); }
static constexpr raw_t mod_(T v) { return redc_mul(norm(i64(v % (std::conditional_t<sint_c<T>, i64, u64>)mod_())), R2); }
static constexpr raw_t mod_() { return MOD; }
constexpr raw_t val_() const {
raw_t res = -mulh(this->v_ * R, mod_());
Expand Down
2 changes: 1 addition & 1 deletion src/code/math/mpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class mpi {
constexpr mpi(T x) : neg(false) {
if constexpr (is_sint_v<T>)
if (x < 0) neg = true, x = -x;
while (x) dt.push_back(u32(to_uint_t<T>(x) % D)), x /= D;
while (x) dt.push_back(u32(to_uint_t<T>(x) % D)), x /= (T)D;
}
constexpr mpi(strn s) : neg(false) {
assert(!s.empty());
Expand Down
20 changes: 10 additions & 10 deletions src/code/math/rational.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ template <int_c T>
struct rational {
T num, den;

constexpr rational(T numerator = 0, T denominator = 1) : num(numerator), den(denominator) {
constexpr rational(T numerator = T(0), T denominator = T(1)) : num(numerator), den(denominator) {
assert(den != 0);
if (num == 0) den = 1;
else {
T g = gcd(num, den);
T g = (T)gcd(num, den);
num /= g, den /= g;
if constexpr (std::is_signed_v<T>)
if (den < 0) num = -num, den = -den;
Expand All @@ -29,37 +29,37 @@ struct rational {
return *this;
}
constexpr rational &operator*=(T x) {
T g = gcd(x, den);
T g = (T)gcd(x, den);
num *= x / g, den /= g;
return *this;
}
constexpr rational &operator/=(T x) {
assert(x);
T g = gcd(x, num);
T g = (T)gcd(x, num);
num /= g, den *= x / g;
if constexpr (std::is_signed_v<T>)
if (den < 0) num = -num, den = -den;
return *this;
}
constexpr rational &operator+=(rational const &x) {
T g = gcd(den, x.den);
num = num * (x.den / g) + x.num * (den /= g), g = gcd(num, g);
T g = (T)gcd(den, x.den);
num = num * (x.den / g) + x.num * (den /= g), g = (T)gcd(num, g);
num /= g, den *= x.den / g;
return *this;
}
constexpr rational &operator-=(rational const &x) {
T g = gcd(den, x.den);
num = num * (x.den / g) - x.num * (den /= g), g = gcd(num, g);
T g = (T)gcd(den, x.den);
num = num * (x.den / g) - x.num * (den /= g), g = (T)gcd(num, g);
num /= g, den *= x.den / g;
return *this;
}
constexpr rational &operator*=(rational const &x) {
T g1 = gcd(num, x.den), g2 = gcd(x.num, den);
T g1 = (T)gcd(num, x.den), g2 = (T)gcd(x.num, den);
num = num / g1 * (x.num / g2), den = den / g2 * (x.den / g1);
return *this;
}
constexpr rational &operator/=(rational const &x) {
T g1 = gcd(num, x.num), g2 = gcd(den, x.den);
T g1 = (T)gcd(num, x.num), g2 = (T)gcd(den, x.den);
num = num / g1 * (x.den / g2), den = den / g2 * (x.num / g1);
if constexpr (std::is_signed_v<T>)
if (den < 0) num = -num, den = -den;
Expand Down
2 changes: 1 addition & 1 deletion src/code/nt/gcd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ constexpr std::common_type_t<T, U> gcd__(T u, U v) {
} // namespace gcd_impl_

template <int_c T, int_c U>
constexpr std::common_type_t<T, U> gcd(T a, U b) { return gcd_impl_::gcd__((to_uint_t<T>)abs(a), (to_uint_t<U>)abs(b)); }
constexpr auto gcd(T a, U b) { return gcd_impl_::gcd__((to_uint_t<T>)abs(a), (to_uint_t<U>)abs(b)); }

} // namespace tifa_libs::math

Expand Down
3 changes: 3 additions & 0 deletions src/code/util/dlx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class DLX {
}

template <class F>
requires requires(F f, vecu sol) {
f(sol);
}
constexpr std::optional<vecu> dance(F &&cb) {
vecu ans;
if (!dance_(ans, std::forward<F>(cb))) return {};
Expand Down
6 changes: 3 additions & 3 deletions src/test_cpverifier/aizu-alds1/alds1_4_c.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ int main() {
std::cin >> s >> t;
u64 x = 0;
for (char c : t) switch (c) {
case 'A': ++x;
case 'C': ++x;
case 'G': ++x;
case 'A': ++x; [[fallthrough]];
case 'C': ++x; [[fallthrough]];
case 'G': ++x; [[fallthrough]];
default: (++x) *= 5;
}
if (s[0] == 'i')
Expand Down
2 changes: 1 addition & 1 deletion src/test_cpverifier/yukicoder/3024.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int main() {
vecu a(n);
std::cin >> a;
vvec<tifa_libs::math::rational<i64>> dp(1 << n);
for (u32 i = 0; i < n; ++i) dp[1 << i].emplace_back(a[i]);
for (u32 i = 0; i < n; ++i) dp[1 << i].emplace_back((i64)a[i]);
for (u32 i = 0, ed_ = 1 << n; i < ed_; ++i) {
if (std::popcount(i) <= 1) continue;
tifa_libs::enum_subset<>::set(i);
Expand Down
6 changes: 3 additions & 3 deletions src/test_tinplate/util/dll_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tifa_libs::util::DLL *gmp;
int t;
char sa[2000010], sb[2000010], sq[2000010];

int main(int argc, char **argv) {
int main(int, char **argv) {
if (getenv("LD_PRELOAD") == nullptr) {
setenv("LD_PRELOAD", LIB_PATH, 1);
execve("/proc/self/exe", argv, environ);
Expand Down Expand Up @@ -45,8 +45,8 @@ int main(int argc, char **argv) {
/*
**statement**
This problem has $T$ cases.
Given hexadecimal integers $A$ and $B$, print hexadecimal integer $AB$.
This problem has $T$ cases.
Given hexadecimal integers $A$ and $B$, print hexadecimal integer $AB$.
**constraints**
Expand Down

0 comments on commit e95cc95

Please sign in to comment.