diff --git a/algorithms/math/big_integer.cpp b/algorithms/math/big_integer.cpp index bc69d5eaec850bdecec2cb4022ae0b3dd1603cf9..ae2bed3770f6ccfdff791dd76aaa93c0a024f72c 100644 --- a/algorithms/math/big_integer.cpp +++ b/algorithms/math/big_integer.cpp @@ -302,8 +302,7 @@ struct BigInt { while (a.size() & (a.size() - 1)) a.pb(0), b.pb(0); - Karatsuba karatsuba; - vector<ll> c = karatsuba.run(a, b); + vector<ll> c = karatsuba(a, b); BigInt res; int carry = 0; diff --git a/algorithms/math/fft.cpp b/algorithms/math/fft.cpp index 7d87d2ffbadcdee2f25fe8ec49934a8887dcfbf8..c4f829f8edfe57fcec88abf732dcee2cc26be6f0 100644 --- a/algorithms/math/fft.cpp +++ b/algorithms/math/fft.cpp @@ -42,12 +42,12 @@ struct FFT { rev.resize(1 << nbase); roots.resize(1 << nbase); - // Construct rev vector + // Build rev vector for (int i = 0; i < (1 << nbase); ++i) rev[i] = (rev[i >> 1] >> 1) + \ ((i & 1) << (nbase - 1)); - // Construct roots vector + // Build roots vector for (int base = 1; base < nbase; ++base) { float angle = 2 * M_PI / (1 << (base + 1)); diff --git a/caderno.pdf b/caderno.pdf index 36941c4bd14d17f3e797b3d264b95d3873ddb0fa..53d0190a3a5725ada0d5ed98b3b139107b0916d9 100644 Binary files a/caderno.pdf and b/caderno.pdf differ diff --git a/contests/SBC16/A.cpp b/contests/SBC16/A.cpp new file mode 100644 index 0000000000000000000000000000000000000000..459038702239650fab2ce663bd56d64de3da6c3e --- /dev/null +++ b/contests/SBC16/A.cpp @@ -0,0 +1,47 @@ +#include <bits/stdc++.h> + +#define EPS 1e-6 +#define MOD 1000000007 +#define inf 0x3f3f3f3f +#define llinf 0x3f3f3f3f3f3f3f3f + +#define fi first +#define se second +#define pb push_back +#define ende '\n' + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define mset(x, y) memset(&x, (y), sizeof(x)) + +using namespace std; + +using ll = long long; +using ii = pair<int,int>; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + vector<int> v(3); + for (auto &i: v) cin >> i; + + bool poss = false; + for (int i = 1; i < 8; ++i) { + for (int j = 0; j < 8; ++j) { + int sum = 0; + for (int k = 0; k < 3; ++k) { + if (i & (1 << k)) { + if (j & (1 << k)) sum += v[k]; + else sum -= v[k]; + } + } + + if (sum == 0) poss = true; + } + } + + if (poss) cout << "S" << ende; + else cout << "N" << ende; + return 0; +} diff --git a/contests/SBC16/H.cpp b/contests/SBC16/H.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b8f9651e7de3cbe7177821d5a624ba214f5532f2 --- /dev/null +++ b/contests/SBC16/H.cpp @@ -0,0 +1,39 @@ +#include <bits/stdc++.h> + +#define EPS 1e-6 +#define MOD 1000000007 +#define inf 0x3f3f3f3f +#define llinf 0x3f3f3f3f3f3f3f3f + +#define fi first +#define se second +#define pb push_back +#define ende '\n' + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define mset(x, y) memset(&x, (y), sizeof(x)) + +using namespace std; + +using ll = long long; +using ii = pair<int,int>; + +bool vowel(char x) { + return (x == 'a') || (x == 'e') || (x == 'i') || (x == 'o') || (x == 'u'); +} + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + string s; cin >> s; + string t, w; + for (auto i : s) if (vowel(i)) t.pb(i); + w = t; + reverse(all(t)); + if (w == t) cout << "S" << ende; + else cout << "N" << ende; + + return 0; +} diff --git a/contests/SBC16/a.out b/contests/SBC16/a.out new file mode 100755 index 0000000000000000000000000000000000000000..71cabd06f9608efa44779b2b5837c4fbe534a032 Binary files /dev/null and b/contests/SBC16/a.out differ diff --git a/contests/SBC18/B.cpp b/contests/SBC18/B.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0931aac673235e5c23807b142565c9b7d7ec871f --- /dev/null +++ b/contests/SBC18/B.cpp @@ -0,0 +1,73 @@ +#include <bits/stdc++.h> + +#define MAX 101 +#define EPS 1e-6 +#define MOD 1000000007 +#define inf 0x3f3f3f3f +#define llinf 0x3f3f3f3f3f3f3f3f + +#define fi first +#define se second +#define pb push_back +#define ende '\n' + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define mset(x, y) memset(&x, (y), sizeof(x)) + +using namespace std; + +using ll = long long; +using ii = pair<int,int>; + +int foi[500]; +int mat[MAX][MAX]; +int dp[MAX][MAX]; + +int main() { + ios::sync_with_stdio(0); + cin.tie(0); + + for (int i = 0; i < MAX; ++i) { + dp[i][0] = 499; + dp[0][i] = 499; + dp[i][i] = 499; + } + + for (int i = 1; i < MAX; ++i) { + for (int j = 1; j < MAX; ++j) { + if (i != j) { + mset(foi, 0); + for (int k = 1; k <= i; ++k) + foi[dp[i-k][j]] = 1; + for (int k = 1; k <= j; ++k) + foi[dp[i][j-k]] = 1; + + int mm = min(i, j); + for (int k = 1; k <= mm; ++k) + foi[dp[i-k][j-k]] = 1; + + int res = -1; + for (int k = 0; k < 500; ++k) + if (!foi[k]) { + res = k; + break; + } + + dp[i][j] = res; + } + } + } + + int ans = 0; + int n; cin >> n; + for (int i = 0; i < n; ++i) { + int a, b; cin >> a >> b; + if (dp[a][b] == 499) + return cout << 'Y' << ende, 0; + ans ^= dp[a][b]; + } + + cout << ((ans) ? 'Y' : 'N') << ende; + return 0; +} diff --git a/gen_notebook b/gen_notebook index 394a48cad6c4558f62a4b2a0fee5b92fa32ba76f..3d13e4727fea35cc45bcc18f77f1282987acf2b0 100755 --- a/gen_notebook +++ b/gen_notebook @@ -1,16 +1,38 @@ #!/bin/bash +output_name="caderno.pdf" + if [ "$1" = "DEBUG" ]; then tex_file=result.tex python3 notebook/gen_latex.py --header=notebook/header.tex --output=$tex_file else tex_file=bft_notebook + + echo "Generating LaTeX file..." python3 notebook/gen_latex.py --header=notebook/header.tex --output=$tex_file + if [ $? -eq 0 ]; then + echo "LaTeX file generated successfully" + else + echo "ERROR on gen_latex.py script" + exit 1 + fi + + echo "Generating PDF..." + # Lualatex must be used in order to work with the correct font - lualatex $tex_file -halt-on-error -output-directory . && - lualatex $tex_file -halt-on-error -output-directory . + # and it must be executed twice to work properly + lualatex -halt-on-error -interaction=nonstopmode $tex_file -output-directory . > latex_log.txt && + lualatex -halt-on-error -interaction=nonstopmode $tex_file -output-directory . > latex_log.txt - mv $tex_file.pdf caderno.pdf - rm $tex_file* + if [ $? -eq 0 ]; then + mv $tex_file.pdf $output_name + rm $tex_file* + rm latex_log.txt + echo "PDF generated successfully: $output_name" + else + rm $tex_file* + echo "ERROR on LaTeX input file: check latex_log.txt" + exit 1 + fi fi