Skip to content

Commit

Permalink
refactor: use fastio
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiphereth-A committed Apr 15, 2024
1 parent 4954ee9 commit eeffc15
Show file tree
Hide file tree
Showing 515 changed files with 2,132 additions and 2,701 deletions.
2 changes: 1 addition & 1 deletion src/code/poly/div_fps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace tifa_libs::math {
template <class mint, class ccore>
constexpr poly<mint, ccore> div_fps(poly<mint, ccore> p, poly<mint, ccore> q) {
u32 n = p.size(), m = q.size();
if (n < m) return {};
if (n < m) return poly<mint, ccore>{};
p.reverse(), q.reverse(), q.resize(n - m + 1);
p.conv(inv_fps(q)), p.resize(n - m + 1), p.reverse();
return p;
Expand Down
7 changes: 3 additions & 4 deletions src/meta_test/library-checker/bernoulli_number.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define PROBLEM "https://judge.yosupo.jp/problem/bernoulli_number"

#include "../../code/comb/gen_bernoulli.hpp"
#include "../../code/io/fastio.hpp"

constexpr u32 MOD = 998244353;

Expand All @@ -14,10 +15,8 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n;
std::cin >> n;
std::cout << tifa_libs::math::gen_bernoulli<poly>(n);
tifa_libs::fin >> n;
tifa_libs::fout << tifa_libs::math::gen_bernoulli<poly>(n).data();
return 0;
}
12 changes: 5 additions & 7 deletions src/meta_test/library-checker/bitwise_and_convolution.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PROBLEM "https://judge.yosupo.jp/problem/bitwise_and_convolution"

#include "../../code/conv/conv_and.hpp"
#include "../../code/io/ios_container.hpp"
#include "../../code/io/fastio.hpp"

constexpr u32 MOD = 998244353;

Expand All @@ -10,13 +10,11 @@ constexpr u32 MOD = 998244353;

int main() {
#define GENTCs_mintd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n;
std::cin >> n;
tifa_libs::fin >> n;
vec<mint> a(1 << n), b(1 << n);
for (auto &i : a) std::cin >> i;
for (auto &i : b) std::cin >> i;
std::cout << tifa_libs::math::conv_and(a, b) << '\n';
for (auto &i : a) tifa_libs::fin >> i;
for (auto &i : b) tifa_libs::fin >> i;
tifa_libs::fout << tifa_libs::math::conv_and(a, b) << '\n';
return 0;
}
12 changes: 5 additions & 7 deletions src/meta_test/library-checker/bitwise_xor_convolution.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PROBLEM "https://judge.yosupo.jp/problem/bitwise_xor_convolution"

#include "../../code/conv/conv_xor.hpp"
#include "../../code/io/ios_container.hpp"
#include "../../code/io/fastio.hpp"
#include "../../code/math/mint_d31.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -11,13 +11,11 @@ constexpr u32 MOD = 998244353;

int main() {
#define GENTCs_mintd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n;
std::cin >> n;
tifa_libs::fin >> n;
vec<mint> a(1 << n), b(1 << n);
for (auto &i : a) std::cin >> i;
for (auto &i : b) std::cin >> i;
std::cout << tifa_libs::math::conv_xor(a, b) << '\n';
for (auto &i : a) tifa_libs::fin >> i;
for (auto &i : b) tifa_libs::fin >> i;
tifa_libs::fout << tifa_libs::math::conv_xor(a, b) << '\n';
return 0;
}
13 changes: 6 additions & 7 deletions src/meta_test/library-checker/division_of_polynomials.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/division_of_polynomials"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/divmod_fps.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,17 +15,15 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n, m;
std::cin >> n >> m;
tifa_libs::fin >> n >> m;
poly f(n), g(m);
std::cin >> f >> g;
tifa_libs::fin >> f.data() >> g.data();
auto [q, r] = tifa_libs::math::divmod_fps(f, g);
if (q.size() == 1 && q[0].val() == 0) q.resize(0);
if (r.size() == 1 && r[0].val() == 0) r.resize(0);
std::cout << q.size() << ' ' << r.size() << '\n';
std::cout << q << '\n';
std::cout << r << '\n';
tifa_libs::fout << q.size() << ' ' << r.size() << '\n';
tifa_libs::fout << q.data() << '\n';
tifa_libs::fout << r.data() << '\n';
return 0;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/exp_of_formal_power_series_sparse"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/exp_fpssp.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,12 +15,10 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n, k;
std::cin >> n >> k;
tifa_libs::fin >> n >> k;
poly p(n);
for (u32 i = 0, x; i < k; ++i) std::cin >> x >> p[x];
std::cout << tifa_libs::math::exp_fpssp(p);
for (u32 i = 0, x; i < k; ++i) tifa_libs::fin >> x >> p[x];
tifa_libs::fout << tifa_libs::math::exp_fpssp(p).data();
return 0;
}
10 changes: 4 additions & 6 deletions src/meta_test/library-checker/exp_of_set_power_series.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/exp_of_set_power_series"

#include "../../code/io/ios_container.hpp"
#include "../../code/io/fastio.hpp"
#include "../../code/poly/exp_fpssps.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -10,12 +10,10 @@ constexpr u32 MOD = 998244353;

int main() {
#define GENTCs_mintd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n;
std::cin >> n;
tifa_libs::fin >> n;
vec<mint> b(1 << n);
std::cin >> b;
std::cout << tifa_libs::math::exp_fpssps(n, b) << '\n';
tifa_libs::fin >> b;
tifa_libs::fout << tifa_libs::math::exp_fpssps(n, b) << '\n';
return 0;
}
9 changes: 4 additions & 5 deletions src/meta_test/library-checker/inv_of_formal_power_series.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/inv_of_formal_power_series"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/inv_fps.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,12 +15,10 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n;
std::cin >> n;
tifa_libs::fin >> n;
poly p(n);
std::cin >> p;
std::cout << tifa_libs::math::inv_fps(p);
tifa_libs::fin >> p;
tifa_libs::fout << tifa_libs::math::inv_fps(p).data();
return 0;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/inv_of_formal_power_series_sparse"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/inv_fpssp.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,12 +15,10 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n, k;
std::cin >> n >> k;
tifa_libs::fin >> n >> k;
poly p(n);
for (u32 i = 0, x; i < k; ++i) std::cin >> x >> p[x];
std::cout << tifa_libs::math::inv_fpssp(p);
for (u32 i = 0, x; i < k; ++i) tifa_libs::fin >> x >> p[x];
tifa_libs::fout << tifa_libs::math::inv_fpssp(p).data();
return 0;
}
15 changes: 7 additions & 8 deletions src/meta_test/library-checker/inv_of_polynomials.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/inv_of_polynomials"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/modinv_fps.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,16 +15,14 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n, m;
std::cin >> n >> m;
tifa_libs::fin >> n >> m;
poly a(n), b(m);
std::cin >> a >> b;
tifa_libs::fin >> a.data() >> b.data();
auto _ = tifa_libs::math::modinv_fps(a, b);
if (!_.has_value()) std::cout << "-1\n";
else if (_.value().empty()) std::cout << "0\n";
else std::cout << _.value().size() << '\n'
<< _.value() << '\n';
if (!_.has_value()) tifa_libs::fout << "-1\n";
else if (_.value().empty()) tifa_libs::fout << "0\n";
else tifa_libs::fout << _.value().size() << '\n'
<< _.value().data() << '\n';
return 0;
}
9 changes: 4 additions & 5 deletions src/meta_test/library-checker/log_of_formal_power_series.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/log_of_formal_power_series"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/ln_fps.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,12 +15,10 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n;
std::cin >> n;
tifa_libs::fin >> n;
poly p(n);
std::cin >> p;
std::cout << tifa_libs::math::ln_fps(p);
tifa_libs::fin >> p.data();
tifa_libs::fout << tifa_libs::math::ln_fps(p).data();
return 0;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/log_of_formal_power_series_sparse"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/ln_fpssp.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,12 +15,10 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n, k;
std::cin >> n >> k;
tifa_libs::fin >> n >> k;
poly p(n);
for (u32 i = 0, x; i < k; ++i) std::cin >> x >> p[x];
std::cout << tifa_libs::math::ln_fpssp(p);
for (u32 i = 0, x; i < k; ++i) tifa_libs::fin >> x >> p[x];
tifa_libs::fout << tifa_libs::math::ln_fpssp(p).data();
return 0;
}
9 changes: 4 additions & 5 deletions src/meta_test/library-checker/multipoint_evaluation.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/multipoint_evaluation"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/mpe_fps.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,12 +15,10 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n, m;
std::cin >> n >> m;
tifa_libs::fin >> n >> m;
poly a(n), p(m);
std::cin >> a >> p;
std::cout << tifa_libs::math::mpe_fps(a, p) << '\n';
tifa_libs::fin >> a.data() >> p.data();
tifa_libs::fout << tifa_libs::math::mpe_fps(a, p).data() << '\n';
return 0;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/multipoint_evaluation_on_geometric_sequence"

#include "../../code/io/fastio.hpp"
#include "../../code/poly/czt_fps.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -14,13 +15,11 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n, m;
mint a, r;
std::cin >> n >> m >> a >> r;
tifa_libs::fin >> n >> m >> a >> r;
poly f(n);
std::cin >> f;
std::cout << tifa_libs::math::czt_fps(f, r, m, a) << '\n';
tifa_libs::fin >> f.data();
tifa_libs::fout << tifa_libs::math::czt_fps(f, r, m, a).data() << '\n';
return 0;
}
7 changes: 3 additions & 4 deletions src/meta_test/library-checker/partition_function.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define PROBLEM "https://judge.yosupo.jp/problem/partition_function"

#include "../../code/comb/gen_partition.hpp"
#include "../../code/io/fastio.hpp"

constexpr u32 MOD = 998244353;

Expand All @@ -14,10 +15,8 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 n;
std::cin >> n;
std::cout << tifa_libs::math::gen_partition<poly>(n);
tifa_libs::fin >> n;
tifa_libs::fout << tifa_libs::math::gen_partition<poly>(n).data();
return 0;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define PROBLEM "https://judge.yosupo.jp/problem/polynomial_composite_set_power_series"

#include "../../code/io/ios_container.hpp"
#include "../../code/io/fastio.hpp"
#include "../../code/poly/comp_fpssps.hpp"

constexpr u32 MOD = 998244353;
Expand All @@ -15,14 +15,12 @@ constexpr u32 MOD = 998244353;
int main() {
#define GENTCs_p3nttd1
#define GENTCs_pmttd1
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
u32 m, n;
std::cin >> m >> n;
tifa_libs::fin >> m >> n;
poly a(m);
std::cin >> a;
tifa_libs::fin >> a.data();
vec<mint> b(1 << n);
for (auto &i : b) std::cin >> i;
std::cout << tifa_libs::math::comp_fpssps(n, a, b) << '\n';
for (auto &i : b) tifa_libs::fin >> i;
tifa_libs::fout << tifa_libs::math::comp_fpssps(n, a, b) << '\n';
return 0;
}
Loading

0 comments on commit eeffc15

Please sign in to comment.