diff --git a/codeforces/1017/.clang-format b/codeforces/1017/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1017/.clang-format @@ -0,0 +1,9 @@ +BasedOnStyle: Google +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLambdasOnASingleLine: false +AllowShortLoopsOnASingleLine: false diff --git a/codeforces/1017/.clangd b/codeforces/1017/.clangd new file mode 100644 index 0000000..4c67c32 --- /dev/null +++ b/codeforces/1017/.clangd @@ -0,0 +1,27 @@ +CompileFlags: + Add: + - -std=c++20 + - -Wall + - -Wextra + - -Wshadow + - -Wnon-virtual-dtor + - -Wold-style-cast + - -Wcast-align + - -Wunused + - -Woverloaded-virtual + - -Wpedantic + - -Wconversion + - -Wsign-conversion + - -Wmisleading-indentation + - -Wduplicated-cond + - -Wduplicated-branches + - -Wlogical-op + - -Wnull-dereference + - -Wuseless-cast + - -Wformat=2 + - -Wformat-overflow + - -Wformat-truncation + - -Wdouble-promotion + - -Wundef + - -DLOCAL + - -Wno-unknown-pragmas \ No newline at end of file diff --git a/codeforces/1017/a.cc b/codeforces/1017/a.cc new file mode 100644 index 0000000..df3b388 --- /dev/null +++ b/codeforces/1017/a.cc @@ -0,0 +1,37 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; +// }}} + +void solve() { + string a, b, c; + cin >> a >> b >> c; + cout << a[0] << b[0] << c[0] << endl; +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + int tc = 1; + cin >> tc; + + for (int t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1017/a.in b/codeforces/1017/a.in new file mode 100644 index 0000000..f84b150 --- /dev/null +++ b/codeforces/1017/a.in @@ -0,0 +1,8 @@ +7 +united states america +oh my god +i cant lie +binary indexed tree +believe in yourself +skibidi slay sigma +god bless america diff --git a/codeforces/1017/a.out b/codeforces/1017/a.out new file mode 100644 index 0000000..a9d3fae --- /dev/null +++ b/codeforces/1017/a.out @@ -0,0 +1,10 @@ +a.cc: In function ‘void solve()’: +a.cc:21:31: error: invalid operands of types ‘int’ and ‘’ to binary ‘operator<<’ + 21 | cout << a[0] << b[0] << c[0 << endl; + | ~~^~~~~~~ +a.cc:21:38: error: expected ‘]’ before ‘;’ token + 21 | cout << a[0] << b[0] << c[0 << endl; + | ^ + | ] + +[code]: 1 diff --git a/codeforces/1017/b.cc b/codeforces/1017/b.cc new file mode 100644 index 0000000..dfc6946 --- /dev/null +++ b/codeforces/1017/b.cc @@ -0,0 +1,43 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; +// }}} + +void solve() { + int n, m, l, r; + cin >> n >> m >> l >> r; + + int lp = max(l, -m), rp = lp + m; + if (rp > r) { + rp = r; + lp = rp - m; + } + cout << lp << ' ' << rp << '\n'; +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + int tc = 1; + cin >> tc; + + for (int t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1017/b.in b/codeforces/1017/b.in new file mode 100644 index 0000000..7c6537b --- /dev/null +++ b/codeforces/1017/b.in @@ -0,0 +1,5 @@ +4 +4 2 -2 2 +4 1 0 4 +3 3 -1 2 +9 8 -6 3 diff --git a/codeforces/1017/b.out b/codeforces/1017/b.out new file mode 100644 index 0000000..33f4fa9 --- /dev/null +++ b/codeforces/1017/b.out @@ -0,0 +1,6 @@ +-2 0 +0 1 +-1 2 +-6 2 + +[code]: 0 diff --git a/codeforces/1017/c.cc b/codeforces/1017/c.cc new file mode 100644 index 0000000..977751c --- /dev/null +++ b/codeforces/1017/c.cc @@ -0,0 +1,174 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; +// }}} + +#include +#include + +using namespace __gnu_pbds; + +// https://mirror.codeforces.com/blog/entry/124683 + +namespace hashing { +using i64 = std::int64_t; +using u64 = std::uint64_t; +static const u64 FIXED_RANDOM = + std::chrono::steady_clock::now().time_since_epoch().count(); + +#if USE_AES +std::mt19937 rd(FIXED_RANDOM); +const __m128i KEY1{(i64)rd(), (i64)rd()}; +const __m128i KEY2{(i64)rd(), (i64)rd()}; +#endif + +template +struct custom_hash {}; + +template +inline void hash_combine(u64 &seed, T const &v) { + custom_hash hasher; + seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4); +}; + +template +struct custom_hash::value>::type> { + u64 operator()(T _x) const { + u64 x = _x; +#if USE_AES + __m128i m{i64(u64(x) * 0xbf58476d1ce4e5b9u64), (i64)FIXED_RANDOM}; + __m128i y = _mm_aesenc_si128(m, KEY1); + __m128i z = _mm_aesenc_si128(y, KEY2); + return z[0]; +#else + x += 0x9e3779b97f4a7c15 + FIXED_RANDOM; + x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; + x = (x ^ (x >> 27)) * 0x94d049bb133111eb; + return x ^ (x >> 31); +#endif + } +}; + +template +struct custom_hash()))>> { + u64 operator()(T const &a) const { + u64 value = FIXED_RANDOM; + for (auto &x : a) + hash_combine(value, x); + return value; + } +}; + +template +struct custom_hash> { + u64 operator()(const std::tuple &a) const { + u64 value = FIXED_RANDOM; + std::apply( + [&value](T const &...args) { + (hash_combine(value, args), ...); + }, + a); + return value; + } +}; + +template +struct custom_hash> { + u64 operator()(std::pair const &a) const { + u64 value = FIXED_RANDOM; + hash_combine(value, a.first); + hash_combine(value, a.second); + return value; + } +}; +}; // namespace hashing + +#ifdef PB_DS_ASSOC_CNTNR_HPP +template +using hashtable = gp_hash_table< + Key, Value, hashing::custom_hash, std::equal_to, + direct_mask_range_hashing<>, linear_probe_fn<>, + hash_standard_resize_policy, + hash_load_check_resize_trigger<>, true>>; + +#endif +#ifdef PB_DS_TREE_POLICY_HPP +template +using multitree = tree, rb_tree_tag, + tree_order_statistics_node_update>; +template +using rbtree = tree, rb_tree_tag, + tree_order_statistics_node_update>; +#endif + +void solve() { + int n; + cin >> n; + vector> grid((size_t)n, vector(size_t(n))); + for (int i = 0; i < n; ++i) { + for (int j = 0; j < n; ++j) { + cin >> grid[i][j]; + } + } + + vector ans(2 * size_t(n) + 1, 0); + hashtable seen; + + for (int k = 2; k <= 2 * n; ++k) { + int x = -1, good = 1; + for (int i = 1; i <= n; ++i) { + int j = k - i; + if (j >= 1 && j <= n) { + if (x == -1) { + x = grid[i - 1][j - 1]; + } else if (grid[i - 1][j - 1] != x) { + good = 0; + break; + } + } + } + if (good && x != -1) { + ans[k] = x; + seen.insert(x); + } + } + + for (int first_candidate = 1; first_candidate <= 2 * n; ++first_candidate) { + if (seen.find(first_candidate) == seen.end()) { + cout << first_candidate << ' '; + for (size_t i = 2; i <= 2 * n; ++i) { + cout << ans[i] << ' '; + } + cout << '\n'; + return; + } + } +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + int tc = 1; + cin >> tc; + + for (int t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1017/c.in b/codeforces/1017/c.in new file mode 100644 index 0000000..b2e786a --- /dev/null +++ b/codeforces/1017/c.in @@ -0,0 +1,10 @@ +3 +3 +1 6 2 +6 2 4 +2 4 3 +1 +1 +2 +2 3 +3 4 diff --git a/codeforces/1017/c.out b/codeforces/1017/c.out new file mode 100644 index 0000000..5afaf36 --- /dev/null +++ b/codeforces/1017/c.out @@ -0,0 +1,5 @@ +5 1 6 2 4 3 +2 1 +1 2 3 4 + +[code]: 0 diff --git a/codeforces/1017/compile_flags.txt b/codeforces/1017/compile_flags.txt new file mode 100644 index 0000000..6d76ca1 --- /dev/null +++ b/codeforces/1017/compile_flags.txt @@ -0,0 +1,24 @@ +-std=c++20 +-Wall +-Wextra +-Wshadow +-Wnon-virtual-dtor +-Wold-style-cast +-Wcast-align +-Wunused +-Woverloaded-virtual +-Wpedantic +-Wconversion +-Wsign-conversion +-Wmisleading-indentation +-Wduplicated-cond +-Wduplicated-branches +-Wlogical-op +-Wnull-dereference +-Wuseless-cast +-Wformat=2 +-Wformat-overflow +-Wformat-truncation +-Wdouble-promotion +-Wundef +-DLOCAL diff --git a/codeforces/1017/d.cc b/codeforces/1017/d.cc new file mode 100644 index 0000000..51950b9 --- /dev/null +++ b/codeforces/1017/d.cc @@ -0,0 +1,43 @@ +#include + +int main() { + int x; + std::cin >> x; + + while (x--) { + std::string p, s; + std::cin >> p >> s; + + size_t pi = 0; + size_t si = 0; + while (pi < p.size() && si < s.size()) { + if (p[pi] != s[si]) { + break; + } + + auto TO_MATCH = p[pi]; + + size_t LEFT_POS_CHANGE = 0; + size_t RIGHT_POST_CHANGE = 0; + while (p[pi] == TO_MATCH) { + ++LEFT_POS_CHANGE; + if (++pi == p.size()) + break; + } + while (s[si] == TO_MATCH) { + ++RIGHT_POST_CHANGE; + if (++si == s.size()) + break; + } + // clamp delta + if (RIGHT_POST_CHANGE < LEFT_POS_CHANGE || + RIGHT_POST_CHANGE > 2 * LEFT_POS_CHANGE) { + break; + } + } + + std::cout << (pi == p.size() && si == s.size() ? "YES\n" : "NO\n"); + } + + return 0; +} diff --git a/codeforces/1017/d.in b/codeforces/1017/d.in new file mode 100644 index 0000000..2adc308 --- /dev/null +++ b/codeforces/1017/d.in @@ -0,0 +1,11 @@ +5 +R +RR +LRLR +LRLR +LR +LLLR +LLLLLRL +LLLLRRLL +LLRLRLRRL +LLLRLRRLLRRRL diff --git a/codeforces/1017/d.out b/codeforces/1017/d.out new file mode 100644 index 0000000..edcf4d7 --- /dev/null +++ b/codeforces/1017/d.out @@ -0,0 +1,7 @@ +YES +YES +NO +NO +YES + +[code]: 0 diff --git a/codeforces/1017/e.cc b/codeforces/1017/e.cc new file mode 100644 index 0000000..ae6d215 --- /dev/null +++ b/codeforces/1017/e.cc @@ -0,0 +1,52 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +void solve() { + size_t n; + cin >> n; + vector a(n); + for (auto& e : a) + cin >> e; + + vector f(30, 0); + for (long long x : a) { + for (size_t bit = 0; bit < 30; ++bit) { + if (x & (1 << bit)) + ++f[bit]; + } + } + + long long ans = 0; + for (long long x : a) { + long long cur = 0; + for (long long bit = 0; bit < 30; ++bit) { + // add left/right accordingly + cur += (x & (1 << bit)) ? ((n - f[bit]) * (1 << bit)) + : (f[bit] * (1 << bit)); + } + ans = max(ans, cur); + } + + cout << ans << '\n'; +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + int tc = 1; + cin >> tc; + + for (long long t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1017/e.in b/codeforces/1017/e.in new file mode 100644 index 0000000..58a3378 --- /dev/null +++ b/codeforces/1017/e.in @@ -0,0 +1,11 @@ +5 +3 +18 18 18 +5 +1 2 4 8 16 +5 +8 13 4 5 15 +6 +625 676 729 784 841 900 +1 +1 diff --git a/codeforces/1017/e.out b/codeforces/1017/e.out new file mode 100644 index 0000000..cf56389 --- /dev/null +++ b/codeforces/1017/e.out @@ -0,0 +1,7 @@ +0 +79 +37 +1555 +0 + +[code]: 0 diff --git a/codeforces/1017/f.cc b/codeforces/1017/f.cc new file mode 100644 index 0000000..2f0f1ed --- /dev/null +++ b/codeforces/1017/f.cc @@ -0,0 +1,59 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; +// }}} + +void solve() { + i32 n, m, k; + cin >> n >> m >> k; + + if (n > m) { + swap(n, m); + } + + // 3x4 -> [1, 2 ,1, 2] + // [2, 1, 2, 1] + // [1, 2, 1, 2] + + // if even # cols/rows -> ez (i.e. either even, swap) + // REDUCE: odd # cols & rows + // [1, 2, 3] + // [2, 3, 1] + // [3, 2, 1] + + + i32 cur = -1; + if (n & 1 && m & 1) { + cur = (cur + 1) % m; + for (i32 i = 0; i < n; ++i) { + for () + } + } +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + int tc = 1; + cin >> tc; + + for (int t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1017/f.in b/codeforces/1017/f.in new file mode 100644 index 0000000..766e406 --- /dev/null +++ b/codeforces/1017/f.in @@ -0,0 +1,4 @@ +3 +2 2 2 +3 4 6 +5 5 25 diff --git a/codeforces/1017/f.out b/codeforces/1017/f.out new file mode 100644 index 0000000..445b8c6 --- /dev/null +++ b/codeforces/1017/f.out @@ -0,0 +1,12 @@ +1 2 +2 1 +1 2 3 4 +2 3 4 5 +3 4 5 6 +1 2 3 4 5 +2 3 4 5 6 +3 4 5 6 7 +4 5 6 7 8 +5 6 7 8 9 + +[code]: 0 diff --git a/codeforces/1017/g.cc b/codeforces/1017/g.cc new file mode 100644 index 0000000..b9ec2db --- /dev/null +++ b/codeforces/1017/g.cc @@ -0,0 +1,73 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; +// }}} + +void solve() { + i32 q; + cin >> q; + + deque dq; + i64 S = 0; + i64 total = 0; + bool reversed = false; + + while (q--) { + i32 cmd; + cin >> cmd; + + if (cmd == 1) { // left cyclic shift + if (reversed) { + S += total - dq.front() * dq.size(); + dq.push_back(dq.front()); + dq.pop_front(); + } else { + S += total - dq.back() * dq.size(); + dq.push_front(dq.back()); + dq.pop_back(); + } + } else if (cmd == 2) { // reverse + S = ((i64)dq.size() + 1) * total - S; + reversed ^= 1; + } else { // append + i64 k; + cin >> k; + if (reversed) { + dq.push_front(k); + } else { + dq.push_back(k); + } + total += k; + S += k * dq.size(); + } + + cout << S << '\n'; + } +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + int tc = 1; + cin >> tc; + + for (int t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1017/g.in b/codeforces/1017/g.in new file mode 100644 index 0000000..f6db8e4 --- /dev/null +++ b/codeforces/1017/g.in @@ -0,0 +1,15 @@ +1 +13 +3 1 +3 2 +3 3 +1 +3 4 +2 +3 5 +1 +3 6 +2 +3 7 +2 +1 diff --git a/codeforces/1017/g.out b/codeforces/1017/g.out new file mode 100644 index 0000000..48ace40 --- /dev/null +++ b/codeforces/1017/g.out @@ -0,0 +1,15 @@ +1 +5 +14 +11 +27 +23 +48 +38 +74 +73 +122 +102 +88 + +[code]: 0 \ No newline at end of file diff --git a/codeforces/1017/h.cc b/codeforces/1017/h.cc new file mode 100644 index 0000000..810b3af --- /dev/null +++ b/codeforces/1017/h.cc @@ -0,0 +1,44 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; +// }}} + +void solve() { + i32 n, q; + cin >> n >> q; + vector a(n); + for (auto& e : a) cin >> e; + i32 k, l, r; + while (q--) { + cin >> k >> l >> r; + // perceived as a[i] / k (WRONG) + // + } +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + int tc = 1; + cin >> tc; + + for (int t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/1017/h.in b/codeforces/1017/h.in new file mode 100644 index 0000000..1ae9d69 --- /dev/null +++ b/codeforces/1017/h.in @@ -0,0 +1,11 @@ +2 +5 3 +2 3 5 7 11 +2 1 5 +2 2 4 +2310 1 5 +4 3 +18 12 8 9 +216 1 2 +48 2 4 +82944 1 4 diff --git a/codeforces/1017/h.out b/codeforces/1017/h.out new file mode 100644 index 0000000..e69de29 diff --git a/codeforces/1017/makefile b/codeforces/1017/makefile new file mode 100644 index 0000000..e454976 --- /dev/null +++ b/codeforces/1017/makefile @@ -0,0 +1,95 @@ +.PHONY: run debug clean setup init + +CXX = g++ +# lefticus.gitbooks.io/cpp-best-practice +CXXFLAGS := -O2 -Wall -Wextra -Wpedantic -Wshadow -Wformat=2 \ + -Wfloat-equal -Wlogical-op -Wshift-overflow=2 -Wnon-virtual-dtor \ + -Wold-style-cast -Wcast-equal -Wuseless-cast -Wno-sign-promotion \ + -Wcast-align -Wunused -Woverloaded-virtual -Wconversion \ + -Wsign-conversion -Wmisleading-indentation -Wduplicated-cond \ + -Wduplicated-branches -Wlogical-op -Wnull-dereference -Wformat=2 \ + -Wformat-overflow -Wformat-truncation -Wdouble-promotion -Wundef \ + -DLOCAL -std=c++20 + +# https://interrupt.memfault.com/blog/best-and-worst-gcc-clang-compiler-flags +DEBUG_CXX_FLAGS := -g3 -fsanitize=address,undefined \ + -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow \ + -fno-sanitize-recover=all -fstack-protector-all -fstack-usage \ + -fno-omit-frame-pointer -fno-inline -ffunction-sections + +DEBUG_CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC + +SRC = $(word 2,$(MAKECMDGOALS)) +BASE = $(basename $(SRC)) +INPUT = $(BASE).in +OUTPUT = $(BASE).out +RUN_BIN = $(BASE).run +DBG_BIN = $(BASE).debug + +TEMPLATE_DIR = ~/.config/cp-template + +.SILENT: + +run: $(RUN_BIN) + $(call execute_binary,$(RUN_BIN)) + +debug: $(DBG_BIN) + $(call execute_binary,$(DBG_BIN)) + +$(RUN_BIN): $(SRC) + test -f $@ && rm $@ || true + $(CXX) @compile_flags.txt $(SRC) -o $@ 2>$(OUTPUT); \ + CODE=$$?; \ + if [ $${CODE} -gt 0 ]; then \ + printf '\n[code]: %s' $${CODE} >>$(OUTPUT); \ + exit $${CODE}; \ + else \ + echo '' >$(OUTPUT); \ + fi + +$(DBG_BIN): $(SRC) + test -f $@ && rm $@ || true + $(CXX) @compile_flags.txt $(DEBUG_CXX_FLAGS) $(SRC) -o $@ 2>$(OUTPUT); \ + CODE=$$?; \ + if [ $${CODE} -gt 0 ]; then \ + printf '\n[code]: %s' $${CODE} >>$(OUTPUT); \ + exit $${CODE}; \ + else \ + echo '' >$(OUTPUT); \ + fi + +define execute_binary + timeout 2s ./$1 < $(INPUT) >$(OUTPUT) 2>&1; \ + CODE=$$?; \ + truncate -s $$(head -n 1000 $(OUTPUT) | wc -c) $(OUTPUT); \ + if [ $${CODE} -ge 124 ]; then \ + MSG=''; \ + case $${CODE} in \ + 124) MSG='TIMEOUT';; \ + 128) MSG='SIGILL';; \ + 130) MSG='SIGABRT';; \ + 131) MSG='SIGBUS';; \ + 136) MSG='SIGFPE';; \ + 135) MSG='SIGSEGV';; \ + 137) MSG='SIGPIPE';; \ + 139) MSG='SIGTERM';; \ + esac; \ + [ -n "$${MSG}" ] && printf '\n[code]: %s (%s)' "$${CODE}" "$${MSG}" >>$(OUTPUT); \ + else \ + printf '\n[code]: %s' $${CODE} >>$(OUTPUT); \ + fi +endef + +clean: + find . -type f -name "*.run" -o -name "*.debug" -o -name "*.su" | xargs rm -f + +setup: + test -f compile_flags.txt || cp $(TEMPLATE_DIR)/compile_flags.txt . + test -f .clangd || cp $(TEMPLATE_DIR)/.clangd . + test -f .clang-format || cp $(TEMPLATE_DIR)/.clang-format . + +init: + make setup + +%: + @: diff --git a/codeforces/799/e.cc b/codeforces/799/e.cc index a81843a..bd6148d 100644 --- a/codeforces/799/e.cc +++ b/codeforces/799/e.cc @@ -45,7 +45,7 @@ void solve() { if (a[l] == 0) { continue; } - // NOTE: while loop instead of maintaing invariant + // NOTE: i wrote a while loop instead of maintaing invariant ++r; while (r < n && a[r] == 0) { ++r; diff --git a/codeforces/799/h.cc b/codeforces/799/h.cc new file mode 100644 index 0000000..755f28b --- /dev/null +++ b/codeforces/799/h.cc @@ -0,0 +1,39 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +#define prln(...) std::println(__VA_ARGS__) +#define pr(...) std::print(__VA_ARGS__) + +#ifdef LOCAL +#define dbgln(...) std::println(__VA_ARGS__) +#define dbg(...) std::print(__VA_ARGS__) +#else +#define dbgln(...) +#define dbg(...) +#endif +// }}} + +void solve() { + +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + int tc = 1; + cin >> tc; + + for (int t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/799/h.in b/codeforces/799/h.in new file mode 100644 index 0000000..e69de29