diff --git a/.gitignore b/.gitignore index 5ce1416..0296075 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,3 @@ build io .clangd -.clang-format diff --git a/README.md b/README.md deleted file mode 100644 index cec2ad2..0000000 --- a/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# competitive programming - -a collection of my competitive programming solutions categorized as follows: - -- `/kattis`: a few ICPC problems from UVA's "practices" -- `/codeforces`: codeforces contests, including every division 4 round -- `/cses`: ~100 basic cses problems diff --git a/atcoder/042/.clang-format b/atcoder/042/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/atcoder/042/.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/1003/.clang-format b/codeforces/1003/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1003/.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/1006/.clang-format b/codeforces/1006/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1006/.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/1009/.clang-format b/codeforces/1009/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1009/.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/1013/.clang-format b/codeforces/1013/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1013/.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/1016/.clang-format b/codeforces/1016/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1016/.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/.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/1020/.clang-format b/codeforces/1020/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1020/.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/.clang-format b/codeforces/1027/.clang-format similarity index 96% rename from codeforces/.clang-format rename to codeforces/1027/.clang-format index 59cd6f1..99733d1 100644 --- a/codeforces/.clang-format +++ b/codeforces/1027/.clang-format @@ -1,5 +1,5 @@ BasedOnStyle: LLVM -IndentWidth: 2 +IndentWidth: 4 UseTab: Never AllowShortIfStatementsOnASingleLine: Never diff --git a/codeforces/1029/.clang-format b/codeforces/1029/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1029/.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/1032/.clang-format b/codeforces/1032/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1032/.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/1034/.clang-format b/codeforces/1034/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1034/.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/1037/.clang-format b/codeforces/1037/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1037/.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/1037/a.cc b/codeforces/1037/a.cc index bac1114..47ffe9d 100644 --- a/codeforces/1037/a.cc +++ b/codeforces/1037/a.cc @@ -82,4 +82,5 @@ int main() { // {{{ } return 0; -} // vim: set foldmethod=marker foldmarker={{{{{{,}}}}}} +} +// }}} diff --git a/codeforces/1042/.clang-format b/codeforces/1042/.clang-format new file mode 100644 index 0000000..d2c38f2 --- /dev/null +++ b/codeforces/1042/.clang-format @@ -0,0 +1,5 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 100 +BreakBeforeBraces: Allman +PointerAlignment: Left diff --git a/codeforces/1043/.clang-format b/codeforces/1043/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/1043/.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/1047/.clang-format b/codeforces/1047/.clang-format new file mode 100644 index 0000000..d2c38f2 --- /dev/null +++ b/codeforces/1047/.clang-format @@ -0,0 +1,5 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 100 +BreakBeforeBraces: Allman +PointerAlignment: Left diff --git a/codeforces/1059/.clang-format b/codeforces/1059/.clang-format new file mode 100644 index 0000000..d2c38f2 --- /dev/null +++ b/codeforces/1059/.clang-format @@ -0,0 +1,5 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 100 +BreakBeforeBraces: Allman +PointerAlignment: Left diff --git a/codeforces/1070/a.cc b/codeforces/1070/a.cc deleted file mode 100644 index dc8702a..0000000 --- a/codeforces/1070/a.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> t; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1071/a.cc b/codeforces/1071/a.cc deleted file mode 100644 index 93807a7..0000000 --- a/codeforces/1071/a.cc +++ /dev/null @@ -1,62 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} - -// }}} - -// vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1073/a.cc b/codeforces/1073/a.cc deleted file mode 100644 index 805d4f6..0000000 --- a/codeforces/1073/a.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1073/b1.cc b/codeforces/1073/b1.cc deleted file mode 100644 index 805d4f6..0000000 --- a/codeforces/1073/b1.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1074/a.cc b/codeforces/1074/a.cc deleted file mode 100644 index b2e4942..0000000 --- a/codeforces/1074/a.cc +++ /dev/null @@ -1,62 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - for (u32 i = 1; i <= n; ++i) { - print("{}{}", i, " \n"[i==n]); - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1074/b.cc b/codeforces/1074/b.cc deleted file mode 100644 index b3942f1..0000000 --- a/codeforces/1074/b.cc +++ /dev/null @@ -1,66 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - u64 x = 0, a; - for (u32 i = 1; i <= n; ++i) { - cin >> a; - x = max(x, a); - } - - println("{}", x * n); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1074/c.cc b/codeforces/1074/c.cc deleted file mode 100644 index ba0251d..0000000 --- a/codeforces/1074/c.cc +++ /dev/null @@ -1,78 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - vector a(n); - for (auto &e : a) - cin >> e; - - sort(begin(a), end(a)); - a.erase(unique(begin(a), end(a)), end(a)); - - u32 ans = 1, streak = 1; - - for (u32 i = 1; i < a.size(); ++i) { - if (i > 0 && a[i] - 1 == a[i - 1]) { - ++streak; - } else { - ans = max(ans, streak); - streak = 1; - } - } - - ans = max(ans, streak); - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1074/d.cc b/codeforces/1074/d.cc deleted file mode 100644 index 6a5d1a0..0000000 --- a/codeforces/1074/d.cc +++ /dev/null @@ -1,83 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -bitset<2 * 100000 + 1> dirty; -void solve() { - dirty.reset(); - u32 n, m; - u64 h; - cin >> n >> m >> h; - vector> a(n); - for (u32 i = 0; i < n; ++i) { - cin >> a[i].first; - a[i].second = a[i].first; - } - - u64 b, c; - for (u32 i = 0; i < m; ++i) { - cin >> b >> c; - --b; - if (dirty[b]) { - dirty[b] = false; - a[b].second = a[b].first; - } - a[b].second += c; - if (a[b].second > h) { - dirty.set(); - } - } - - for (u32 i = 0; i < n; ++i) { - print("{}{}", dirty[i] ? a[i].first : a[i].second, " \n"[i == n - 1]); - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1074/e.cc b/codeforces/1074/e.cc deleted file mode 100644 index 42ab639..0000000 --- a/codeforces/1074/e.cc +++ /dev/null @@ -1,71 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n, m, k; - string s; - - cin >> n >> m >> k; - - vector a(n), b(m); - - for (u32 i = 0; i < n; ++i) { - cin >> a[i]; - } - - for (u32 i = 0; i < m; ++i) { - cin >> b[i]; - } - - cin >> s; -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/1074/f.cc b/codeforces/1074/f.cc deleted file mode 100644 index 805d4f6..0000000 --- a/codeforces/1074/f.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#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; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} // vim: set foldmethod=marker foldmarker={{{,}}} diff --git a/codeforces/17/.clang-format b/codeforces/17/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/17/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/19/.clang-format b/codeforces/19/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/19/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/431/.clang-format b/codeforces/431/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/431/.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/479/.clang-format b/codeforces/479/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/479/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/498/.clang-format b/codeforces/498/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/498/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/506/.clang-format b/codeforces/506/.clang-format new file mode 100644 index 0000000..b1ea9ab --- /dev/null +++ b/codeforces/506/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/515/.clang-format b/codeforces/515/.clang-format new file mode 100644 index 0000000..d2c38f2 --- /dev/null +++ b/codeforces/515/.clang-format @@ -0,0 +1,5 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 100 +BreakBeforeBraces: Allman +PointerAlignment: Left diff --git a/codeforces/544/.clang-format b/codeforces/544/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/544/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/547/.clang-format b/codeforces/547/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/547/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/550/.clang-format b/codeforces/550/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/550/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/552/.clang-format b/codeforces/552/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/552/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/555/.clang-format b/codeforces/555/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/555/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/560/.clang-format b/codeforces/560/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/560/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/565/.clang-format b/codeforces/565/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/565/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/570/.clang-format b/codeforces/570/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/570/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/575/.clang-format b/codeforces/575/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/575/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/611/.clang-format b/codeforces/611/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/611/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/640/.clang-format b/codeforces/640/.clang-format new file mode 100644 index 0000000..5625628 --- /dev/null +++ b/codeforces/640/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: Google +AllowShortFunctionsOnASingleLine: Empty diff --git a/codeforces/702/a.cc b/codeforces/702/a.cc deleted file mode 100644 index fb87a87..0000000 --- a/codeforces/702/a.cc +++ /dev/null @@ -1,78 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - vector a(n); - for(auto& e : a) cin >> e; - - u32 ans = 0; - - for (u32 i = 1; i < n; ++i) { - u32 A = max(a[i - 1], a[i]); - u32 B = min(a[i - 1], a[i]); - - while (B * 2 < A) { - ++ans; - B *= 2; - } - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/710/a.cc b/codeforces/710/a.cc deleted file mode 100644 index 9f91d01..0000000 --- a/codeforces/710/a.cc +++ /dev/null @@ -1,67 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - i64 n, m, x; - cin >> n >> m >> x; - - i64 row = x % n; - if (row == 0) - row = n; - i64 col = (x + n - 1) / n; - - println("{}", (row - 1) * m + col); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/713/a.cc b/codeforces/713/a.cc deleted file mode 100644 index 6674b36..0000000 --- a/codeforces/713/a.cc +++ /dev/null @@ -1,73 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - vector a(n); - map f; - for (auto &e : a) { - cin >> e; - ++f[e]; - } - - for (u32 i = 0; i < n; ++i) { - if (f[a[i]] == 1) { - println("{}", i + 1); - return; - } - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/719/a.cc b/codeforces/719/a.cc deleted file mode 100644 index 24663c4..0000000 --- a/codeforces/719/a.cc +++ /dev/null @@ -1,81 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -bitset<26> seen; - -void solve() { - seen.reset(); - u32 n; - string s; - cin >> n >> s; - - for (u32 i = 0; i < n; ++i) { - if (seen[s[i]]) { - println("NO"); - return; - } - - seen[s[i]] = true; - - while (i + 1 < n && s[i] == s[i + 1]) { - ++i; - } - } - - println("YES"); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/725/a.cc b/codeforces/725/a.cc deleted file mode 100644 index 4af7488..0000000 --- a/codeforces/725/a.cc +++ /dev/null @@ -1,68 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - i32 n; - cin >> n; - vector a(n); - for (auto &e : a) - cin >> e; - - i32 i = distance(begin(a), max_element(begin(a), end(a))); - i32 j = distance(begin(a), min_element(begin(a), end(a))); - - println("{}", min({max(i, j) + 1, n - min(i, j), min(i, j) + 1 + n - max(i, j)})); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/731/a.cc b/codeforces/731/a.cc deleted file mode 100644 index 7eee3c5..0000000 --- a/codeforces/731/a.cc +++ /dev/null @@ -1,69 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - i32 x1, y1, x2, y2, x3, y3; - cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3; - - i32 ans = abs(y2 - y1) + abs(x2 - x1); - if (x1 == x2 && x2 == x3 && min(y1, y2) <= y3 && y3 <= max(y1, y2)) { - ans += 2; - } else if (y1 == y2 && y2 == y3 && min(x1, x2) <= x3 && x3 <= max(x1, x2)) { - ans += 2; - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/734/a.cc b/codeforces/734/a.cc deleted file mode 100644 index 904c9f1..0000000 --- a/codeforces/734/a.cc +++ /dev/null @@ -1,65 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - - array ans{0, n / 3, n / 3}; - ++ans[n % 3]; - - println("{} {}", ans[1], ans[2]); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/739/a.cc b/codeforces/739/a.cc deleted file mode 100644 index 43272b9..0000000 --- a/codeforces/739/a.cc +++ /dev/null @@ -1,70 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 k; - cin >> k; - - u32 ans = 1, i = 1; - while (i < k) { - ++ans; - if (!(ans % 3 == 0 || ans % 10 == 3)) { - ++i; - } - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/744/a.cc b/codeforces/744/a.cc deleted file mode 100644 index 458dda6..0000000 --- a/codeforces/744/a.cc +++ /dev/null @@ -1,70 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - string s; - cin >> s; - - u32 b = 0; - for (auto c : s) - b += c == 'B'; - - if (s.size() % 2 == 0 && b == s.size() / 2) { - println("YES"); - } else { - println("NO"); - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/748/a.cc b/codeforces/748/a.cc deleted file mode 100644 index 03923a1..0000000 --- a/codeforces/748/a.cc +++ /dev/null @@ -1,65 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - i32 a, b, c; - cin >> a >> b >> c; - - println("{} {} {}", - max({0, b - a + 1, c - a + 1}), - max({0, a - b + 1, c - b + 1}), - max({0, b - c + 1, a - c + 1})); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/753/a.cc b/codeforces/753/a.cc deleted file mode 100644 index fe30e22..0000000 --- a/codeforces/753/a.cc +++ /dev/null @@ -1,73 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - string a, s; - cin >> a >> s; - map m; - for (u32 i = 0; i < a.size(); ++i) { - m[a[i]] = i; - } - - i32 ans = 0; - for (i32 i = 1; i < s.size(); ++i) { - ans += abs(m[s[i]] - m[s[i - 1]]); - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/756/a.cc b/codeforces/756/a.cc deleted file mode 100644 index b4c1e93..0000000 --- a/codeforces/756/a.cc +++ /dev/null @@ -1,76 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - string s; - cin >> s; - - if ((s.back() - '0') % 2 == 0) { - println("0"); - } else if ((s[0] - '0') % 2 == 0) { - println("1"); - } else { - for (auto c : s) { - if ((c - '0') % 2 == 0) { - println("2"); - return; - } - } - println("-1"); - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/760/a.cc b/codeforces/760/a.cc deleted file mode 100644 index df261aa..0000000 --- a/codeforces/760/a.cc +++ /dev/null @@ -1,65 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - vector ss(7); - for (auto& e : ss) cin >> e; - sort(begin(ss), end(ss)); - - println("{} {} {}", ss[0], ss[1], ss.back() - (ss[0] + ss[1])); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/762/.clang-format b/codeforces/762/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/762/.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/764/a.cc b/codeforces/764/a.cc deleted file mode 100644 index 443625f..0000000 --- a/codeforces/764/a.cc +++ /dev/null @@ -1,65 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - vector a(n); - for (auto &e : a) - cin >> e; - - println("{}", *max_element(begin(a), end(a)) - *min_element(begin(a), end(a))); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/776/a.cc b/codeforces/776/a.cc deleted file mode 100644 index 7bd90b5..0000000 --- a/codeforces/776/a.cc +++ /dev/null @@ -1,72 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - char c; - string s; - cin >> s >> c; - - for (u32 i = 0; i < s.size(); ++i) { - if (s[i] == c && i % 2 == 0 && (s.size() - i - 1) % 2 == 0) { - println("YES"); - return; - } - } - - println("NO"); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/780/a.cc b/codeforces/780/a.cc deleted file mode 100644 index a88876e..0000000 --- a/codeforces/780/a.cc +++ /dev/null @@ -1,69 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 a, b; - cin >> a >> b; - if (b == 0) { - println("{}", a + 1); - } else if (a == 0) { - println("{}", 1); - } else { - println("{}", 2 * b + a + 1); - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/784/.clang-format b/codeforces/784/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/784/.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/786/a.cc b/codeforces/786/a.cc deleted file mode 100644 index caa37ca..0000000 --- a/codeforces/786/a.cc +++ /dev/null @@ -1,66 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 x, y; - cin >> x >> y; - - if (y % x > 0) { - println("0 0"); - } else { - println("1 {}", y / x); - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/787/a.cc b/codeforces/787/a.cc deleted file mode 100644 index f94437f..0000000 --- a/codeforces/787/a.cc +++ /dev/null @@ -1,78 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 a, b, c, y, x; - cin >> a >> b >> c >> x >> y; - - x -= min(x, a); - y -= min(y, b); - - if (x > 0) { - u32 diff = min(x, c); - x -= diff; - c -= diff; - } - - if (y > 0) { - u32 diff = min(y, c); - y -= diff; - } - - println("{}", (x == y && x == 0) ? "YES" : "NO"); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/790/.clang-format b/codeforces/790/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/790/.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/797/a.cc b/codeforces/797/a.cc deleted file mode 100644 index 960e964..0000000 --- a/codeforces/797/a.cc +++ /dev/null @@ -1,80 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - - u32 a = n / 3, b = n / 3, c = n / 3; - - switch (n % 3) { - case 0: - ++b; - --c; - break; - case 1: - b += 2; - --c; - break; - case 2: - ++a; - b += 2; - --c; - break; - } - - println("{} {} {}", a, b, c); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/799/.clang-format b/codeforces/799/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/799/.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/805/a.cc b/codeforces/805/a.cc deleted file mode 100644 index 6eb8282..0000000 --- a/codeforces/805/a.cc +++ /dev/null @@ -1,73 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - u32 N = n; - u32 dcount = 0; - while (N > 0) { - ++dcount; - N /= 10; - } - - u32 base = 1; - for (u32 i = 0; i + 1 < dcount; ++i) { - base *= 10; - } - - println("{}", n - base); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/806/.clang-format b/codeforces/806/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/806/.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/811/a.cc b/codeforces/811/a.cc deleted file mode 100644 index 44fd9d6..0000000 --- a/codeforces/811/a.cc +++ /dev/null @@ -1,75 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - i32 n, H, M, h, m; - cin >> n >> H >> M; - - i32 ans = 24 * 60; - - for (i32 i = 0; i < n; ++i) { - cin >> h >> m; - i32 diff = h * 60 + m - (H * 60 + M); - if (diff < 0) { - diff += 24 * 60; - } - ans = min(ans, diff); - } - - println("{} {}", ans / 60, ans % 60); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/817/.clang-format b/codeforces/817/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/817/.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/820/a.cc b/codeforces/820/a.cc deleted file mode 100644 index 60d462d..0000000 --- a/codeforces/820/a.cc +++ /dev/null @@ -1,69 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - i32 a, b, c; - cin >> a >> b >> c; - - i32 A = a - 1; - i32 B = abs(c - b) + c - 1; - - if (A == B) { - println("3"); - } else { - println("{}", A < B ? 1 : 2); - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/827/.clang-format b/codeforces/827/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/827/.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/834/a.cc b/codeforces/834/a.cc deleted file mode 100644 index c70dd81..0000000 --- a/codeforces/834/a.cc +++ /dev/null @@ -1,74 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -string Yes = "Yes"; - -void solve() { - string s; - cin >> s; - - for (u32 i = 0; i < s.size(); ++i) { - auto c = s[i]; - if (Yes.find(c) == string::npos || - i + 1 < s.size() && !(c == 'Y' && s[i + 1] == 'e' || c == 'e' && s[i + 1] == 's' || - c == 's' && s[i + 1] == 'Y')) { - println("NO"); - return; - } - } - - println("YES"); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/835/.clang-format b/codeforces/835/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/835/.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/839/a.cc b/codeforces/839/a.cc deleted file mode 100644 index 23f52a1..0000000 --- a/codeforces/839/a.cc +++ /dev/null @@ -1,64 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - string s; - cin >> s; - - println("{}", s[0] - '0' + s[2] - '0'); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/847/a.cc b/codeforces/847/a.cc deleted file mode 100644 index 833e241..0000000 --- a/codeforces/847/a.cc +++ /dev/null @@ -1,71 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -string PI = "3141592653589793238462643383279"; - -void solve() { - string s; - cin >> s; - - u32 i = 0; - while (i < PI.size() && s[i] == PI[i]) { - ++i; - } - - println("{}", i); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/849/.clang-format b/codeforces/849/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/849/.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/855/a.cc b/codeforces/855/a.cc deleted file mode 100644 index f39bb2b..0000000 --- a/codeforces/855/a.cc +++ /dev/null @@ -1,81 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - string s; - cin >> n >> s; - - // NOTE: cannot due `for (auto c : "meow")` <- c-style string, includes null-terminator - string S{"meow"}; - - u32 i = 0; - for (auto c : S) { - u32 j = i; - while (j < n && tolower(s[j]) == c) { - ++j; - } - if (i == j) { - i = 0; - break; - } - i = j; - } - - println("{}", i == n ? "YES" : "NO"); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/859/.clang-format b/codeforces/859/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/859/.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/863/a.cc b/codeforces/863/a.cc deleted file mode 100644 index 2966e2d..0000000 --- a/codeforces/863/a.cc +++ /dev/null @@ -1,73 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - char d; - string s; - cin >> n >> d >> s; - - for (u32 i = 0; i < n; ++i) { - if (d > s[i] || d == s[i] && i + 1 < n && d > s[i + 1]) { - println("{}{}{}", s.substr(0, i), d, s.substr(i)); - return; - } - } - - println("{}{}", s, d); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/867/a.cc b/codeforces/867/a.cc deleted file mode 100644 index 91553bd..0000000 --- a/codeforces/867/a.cc +++ /dev/null @@ -1,74 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n, t; - cin >> n >> t; - array ans{-1, -1}; - vector a(n), b(n); - for (u32 i = 0; i < n; ++i) { - cin >> a[i]; - } - for (u32 i = 0; i < n; ++i) { - cin >> b[i]; - } - for (u32 i = 1; i <= n; ++i) { - if (i - 1 + a[i - 1] <= t) { - ans = max(ans, {b[i - 1], i}); - } - } - println("{}", ans[1] == -1 ? -1 : ans[1]); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/871/.clang-format b/codeforces/871/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/871/.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/874/.clang-format b/codeforces/874/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/874/.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/878/a.cc b/codeforces/878/a.cc deleted file mode 100644 index 96696d4..0000000 --- a/codeforces/878/a.cc +++ /dev/null @@ -1,75 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - string s; - cin >> n >> s; - - u32 i = 0; - string ans; - for (u32 j = 1; j < n; ++j) { - if (s[j] == s[i]) { - ans.push_back(s[i]); - i = j + 1; - ++j; - } - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/881/a.cc b/codeforces/881/a.cc deleted file mode 100644 index 0bd367b..0000000 --- a/codeforces/881/a.cc +++ /dev/null @@ -1,74 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - vector a(n); - for (auto& e : a) cin >> e; - - sort(begin(a), end(a)); - - u32 ans = 0; - - for (u32 i = 0; i < n / 2; ++i) { - ans += a[n - i - 1] - a[i]; - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/886/.clang-format b/codeforces/886/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/886/.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/888/.clang-format b/codeforces/888/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/888/.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/891/.clang-format b/codeforces/891/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/891/.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/894/.clang-format b/codeforces/894/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/894/.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/895/.clang-format b/codeforces/895/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/895/.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/898/.clang-format b/codeforces/898/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/898/.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/900/.clang-format b/codeforces/900/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/900/.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/903/.clang-format b/codeforces/903/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/903/.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/905/a.cc b/codeforces/905/a.cc deleted file mode 100644 index 23f7ae5..0000000 --- a/codeforces/905/a.cc +++ /dev/null @@ -1,78 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -string keys = "1234567890"; -vector m(10); - -void solve() { - string s; - cin >> s; - - u32 ans = 4; - - char last = '1'; - for (auto c : s) { - ans += abs(m[c - '0'] - m[last - '0']); - last = c; - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (i32 i = 0; i < keys.size(); ++i) { - m[keys[i] - '0'] = i; - } - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/909/a.cc b/codeforces/909/a.cc deleted file mode 100644 index 1a56db3..0000000 --- a/codeforces/909/a.cc +++ /dev/null @@ -1,67 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - if (n % 3 == 1 || n % 3 == 2) { - println("First"); - } else { - println("Second"); - } -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/913/a.cc b/codeforces/913/a.cc deleted file mode 100644 index 3ac3a12..0000000 --- a/codeforces/913/a.cc +++ /dev/null @@ -1,79 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template constexpr T MIN = std::numeric_limits::min(); - -template constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - char C; - u32 x; - cin >> C >> x; - - for (u32 r = 1; r <= 8; ++r) { - if (r == x) { - continue; - } - - println("{}{}", C, r); - } - - for (char c = 'a'; c <= 'h'; ++c) { - if (c == C) { - continue; - } - - println("{}{}", c, x); - } - - println(); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/916/a.cc b/codeforces/916/a.cc deleted file mode 100644 index 78df74f..0000000 --- a/codeforces/916/a.cc +++ /dev/null @@ -1,79 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -vector f('Z' - 'A' + 1); - -void solve() { - u32 n; - cin >> n; - string s; - cin >> s; - f.assign(f.size(), 0); - - for (auto& e : s) { - ++f[e - 'A']; - } - - u32 ans = 0; - - for (u32 i = 1; i <= f.size(); ++i) { - ans += f[i - 1] >= i; - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/918/.clang-format b/codeforces/918/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/918/.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/920/.clang-format b/codeforces/920/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/920/.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/923/.clang-format b/codeforces/923/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/923/.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/925/a.cc b/codeforces/925/a.cc deleted file mode 100644 index c716e65..0000000 --- a/codeforces/925/a.cc +++ /dev/null @@ -1,76 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -map m; - -void solve() { - u32 n; - cin >> n; - - string ans = "aaa"; - - u32 index = 2; - for (u32 i = 1; i <= n - 3; ++i) { - if (ans[index] == 'z') { - --index; - } - ++ans[index]; - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/927/a.cc b/codeforces/927/a.cc deleted file mode 100644 index 5bfa67a..0000000 --- a/codeforces/927/a.cc +++ /dev/null @@ -1,78 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n; - cin >> n; - string s; - cin >> s; - - u32 ans = 0; - char last = '.'; - for (auto c : s) { - if (last == '*' && c == '*') { - break; - } - if (c == '@') { - ++ans; - } - last = c; - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/928/.clang-format b/codeforces/928/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/928/.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/929/.clang-format b/codeforces/929/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/929/.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/933/a.cc b/codeforces/933/a.cc deleted file mode 100644 index b160b8f..0000000 --- a/codeforces/933/a.cc +++ /dev/null @@ -1,77 +0,0 @@ -#include // {{{ - -#include -#ifdef __cpp_lib_ranges_enumerate -#include -namespace rv = std::views; -namespace rs = std::ranges; -#endif - -#pragma GCC optimize("O2,unroll-loops") -#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") - -using namespace std; - -using i16 = int16_t; -using u16 = uint16_t; -using i32 = int32_t; -using u32 = uint32_t; -using i64 = int64_t; -using u64 = uint64_t; -using f64 = double; -using f128 = long double; - -#if __cplusplus >= 202002L -template -constexpr T MIN = std::numeric_limits::min(); - -template -constexpr T MAX = std::numeric_limits::max(); -#endif - -#ifdef LOCAL -#define db(...) std::print(__VA_ARGS__) -#define dbln(...) std::println(__VA_ARGS__) -#else -#define db(...) -#define dbln(...) -#endif -// }}} - -void solve() { - u32 n, m, k; - cin >> n >> m >> k; - vector a(n), b(m); - for (auto& e : a) cin >> e; - for (auto& e : b) cin >> e; - - u32 ans = 0; - - for (u32 i = 1; i <= n; ++i) { - for (u32 j = 1; j <= m; ++j) { - if (a[i - 1] + b[j - 1] <= k) { - ++ans; - } - } - } - - println("{}", ans); -} - -int main() { // {{{ - std::cin.exceptions(std::cin.failbit); -#ifdef LOCAL - std::cerr.rdbuf(std::cout.rdbuf()); - std::cout.setf(std::ios::unitbuf); - std::cerr.setf(std::ios::unitbuf); -#else - std::cin.tie(nullptr)->sync_with_stdio(false); -#endif - u32 tc = 1; - std::cin >> tc; - for (u32 t = 0; t < tc; ++t) { - solve(); - } - return 0; -} -// }}} diff --git a/codeforces/935/.clang-format b/codeforces/935/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/935/.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/937/.clang-format b/codeforces/937/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/937/.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/938/.clang-format b/codeforces/938/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/938/.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/943/.clang-format b/codeforces/943/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/943/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/944/.clang-format b/codeforces/944/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/944/.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/946/.clang-format b/codeforces/946/.clang-format new file mode 100644 index 0000000..cbec8b9 --- /dev/null +++ b/codeforces/946/.clang-format @@ -0,0 +1,4 @@ +BasedOnStyle: Google +IndentWidth: 2 +ColumnLimit: 100 +PointerAlignment: Left diff --git a/codeforces/950/.clang-format b/codeforces/950/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/950/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/952/.clang-format b/codeforces/952/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/952/.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/954/.clang-format b/codeforces/954/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/954/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/954/a.cc b/codeforces/954/a.cc index 340661e..2c8526a 100644 --- a/codeforces/954/a.cc +++ b/codeforces/954/a.cc @@ -43,7 +43,14 @@ void solve() { for (auto& e : a) cin >> e; sort(begin(a), end(a)); - println("{}", a[1] - a[0] + a[2] - a[1]); + u32 ans = 1e9; + for (i32 c = 1; c <= 10; ++c) { + u32 diff = 0; + for (auto e : a) diff += abs(c - e); + ans = min(ans, diff); + } + + println("{}", ans); } int main() { // {{{ diff --git a/codeforces/957/.clang-format b/codeforces/957/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/957/.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/962/.clang-format b/codeforces/962/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/962/.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/964/.clang-format b/codeforces/964/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/964/.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/966/.clang-format b/codeforces/966/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/966/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/970/.clang-format b/codeforces/970/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/970/.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/971/.clang-format b/codeforces/971/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/971/.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/974/.clang-format b/codeforces/974/.clang-format new file mode 100644 index 0000000..5625628 --- /dev/null +++ b/codeforces/974/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: Google +AllowShortFunctionsOnASingleLine: Empty diff --git a/codeforces/981/.clang-format b/codeforces/981/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/981/.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/988/.clang-format b/codeforces/988/.clang-format new file mode 100644 index 0000000..99733d1 --- /dev/null +++ b/codeforces/988/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +UseTab: Never + +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortLambdasOnASingleLine: None +AllowShortBlocksOnASingleLine: Never +AllowShortEnumsOnASingleLine: false +AllowShortCaseExpressionOnASingleLine: false + +BreakBeforeBraces: Attach +ColumnLimit: 100 +AlignAfterOpenBracket: Align +BinPackArguments: false +BinPackParameters: false diff --git a/codeforces/993/.clang-format b/codeforces/993/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/993/.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/995/.clang-format b/codeforces/995/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/995/.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/996/.clang-format b/codeforces/996/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/996/.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/998/.clang-format b/codeforces/998/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/codeforces/998/.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/cses/dynamic-programming/.clang-format b/cses/dynamic-programming/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/cses/dynamic-programming/.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/cses/graph-algorithms/.clang-format b/cses/graph-algorithms/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/cses/graph-algorithms/.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/cses/introductory-problems/.clang-format b/cses/introductory-problems/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/cses/introductory-problems/.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/cses/range-queries/.clang-format b/cses/range-queries/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/cses/range-queries/.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/cses/sorting-and-searching/.clang-format b/cses/sorting-and-searching/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/cses/sorting-and-searching/.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/kattis/10-9-2024/1/input.txt b/kattis/10-9-2024/1/input.txt deleted file mode 100644 index e69de29..0000000 diff --git a/kattis/10-9-2024/1/script.py b/kattis/10-9-2024/1/script.py deleted file mode 100644 index 8d37a7d..0000000 --- a/kattis/10-9-2024/1/script.py +++ /dev/null @@ -1,15 +0,0 @@ -n, a = list(map(int, input().split())) - -es = list(map(int, input().split())) - -es.sort() - -won = 0 - -for e in es: - if a <= e: - break - won += 1 - a -= (e + 1) - -print(won) diff --git a/kattis/10-9-2024/3/input.txt b/kattis/10-9-2024/3/input.txt deleted file mode 100644 index c68b729..0000000 --- a/kattis/10-9-2024/3/input.txt +++ /dev/null @@ -1,2 +0,0 @@ -10 15 -10 11 12 13 14 15 diff --git a/kattis/10-9-2024/3/script.py b/kattis/10-9-2024/3/script.py deleted file mode 100644 index af25fa5..0000000 --- a/kattis/10-9-2024/3/script.py +++ /dev/null @@ -1,44 +0,0 @@ -from math import gcd - -a, b = map(int, input().split()) -max_num = float('-inf') - -transcript = input().split() - -fizzs = [] -buzzs = [] - -for i, token in enumerate(transcript): - num = a + i - - max_num = max(max_num, num) - - if token.startswith("Fizz") or token.endswith("Fizz"): - fizzs.append(num) - if token.startswith("Buzz") or token.endswith("Buzz"): - buzzs.append(num) - - -def gcf(nums: list[int]) -> int: - if not nums: - return '' - if len(nums) == 1: - return nums[0] - - x, y = nums[0], nums[1] - ans = gcd(x, y) - - for i in range(2, len(nums)): - ans = gcd(ans, nums[i]) - - return ans - - -a, b = gcf(fizzs), gcf(buzzs) - -if a == '': - a = max_num + 1 -if b == '': - b = max_num + 1 - -print(a, b) diff --git a/kattis/10-9-2024/4/script.py b/kattis/10-9-2024/4/script.py deleted file mode 100644 index 5fee760..0000000 --- a/kattis/10-9-2024/4/script.py +++ /dev/null @@ -1,54 +0,0 @@ -N = int(input()) - -matrix: list[list[int]] = [] -for i in range(N): - matrix[i] = list(map(int, list(input()))) - -row_map = [0] * N -col_map = [0] * N - -ones_above = 0 -ones_above_row = [0] * N - -for i, row in enumerate(matrix): - ones_above_row[i] = ones_above - total = 0 - for cell in row: - total += cell - row_map[i] = total - ones_above += row_map[i] - -ones_left = 0 -ones_left_col = [0] * N - -for col in range(N): - total = 0 - for row in range(N): - total += matrix[row][col] - ones_left_col[col] = ones_left - col_map[col] = total - ones_left += col_map[col] - -found_valid_row = False -for i in range(N): - flips_remain = row_map[i] - total_ones = ones_above_row[-1] - row_map[i] + row_map[-1] - if total_ones <= flips_remain: - row_flag = True - break - -found_valid_col = False -for i in range(N): - flips_remain = col_map[i] - total_ones = ones_left_col[-1] - col_map[i] + col_map[-1] - if total_ones <= flips_remain: - found_valid_col = True - break - -if found_valid_row: - if found_valid_col: - print("+") - else: - print("-") -else: - print("-") diff --git a/kattis/10-9-2024/contest.md b/kattis/10-9-2024/contest.md deleted file mode 100644 index 9a0693a..0000000 --- a/kattis/10-9-2024/contest.md +++ /dev/null @@ -1,3 +0,0 @@ -# contest 1 - -https://open.kattis.com/contests/asurii diff --git a/kattis/11-02-2025/.clang-format b/kattis/11-02-2025/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/kattis/11-02-2025/.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/kattis/18-2-2025/.clang-format b/kattis/18-2-2025/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/kattis/18-2-2025/.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/kattis/23-9-24/b/input.txt b/kattis/23-9-24/b/input.txt deleted file mode 100644 index 4165880..0000000 --- a/kattis/23-9-24/b/input.txt +++ /dev/null @@ -1,23 +0,0 @@ -2 - -.#.#.#.#.# -#.#.#.#.#. -.#.#.B.#.# -#.#.#.#.#. -.#.#.B.#.# -#.#.W.#.#. -.#.#.#.#.# -#.#.#.B.#. -.#.#.#.#.# -#.#.#.#.#. - -.#.#.#.#.# -#.#.#.#.#. -.#.#.B.#.# -#.B.#.B.#. -.#.#.B.#.# -#.B.W.#.#. -.#.B.B.#.# -#.#.#.#.#. -.#.B.B.#.# -#.#.#.#.#. diff --git a/kattis/23-9-24/b/solution.py b/kattis/23-9-24/b/solution.py deleted file mode 100644 index e95ce65..0000000 --- a/kattis/23-9-24/b/solution.py +++ /dev/null @@ -1,117 +0,0 @@ -""" -Backtracking Framework -- Set of choices -- Limited by constraints -- To reach a goal - -1. Understand -- Board of W/B, can capture; looking for max consecutive sequence of captures using same piece -- Capture in any direction "skipping over"; land on open square - -Similar Problems: N Queens - -Set of candidates (W pieces) limited in moves (capturing B pieces) to reach max # captures (i.e. capturing moves) -2. Develop - -- Given board state, w/ W candidates -- Consider every candidate as the piece yielding correct answer -- For every candidate, consider every capturing move they can make - - For each move: - - Make the move, and recursively find max # captures using this piece after this capture - - update/restore state on failure - - Update max if new max found - -consider after: caching/optimization - -backtracking function: def max_captures(board, w) -> int: - - -3. Carry Out -4. Revise - -At any particular position, -""" - -BOARD_SIZE = 10 - - -def parse_board() -> tuple[list[list[str]], list[tuple[int, int]]]: - board = [] - candidates: list[tuple[int, int]] = [] - - input() - - for r in range(BOARD_SIZE): - board.append(list(input())) - - candidates.extend((r, c) for c, cell in enumerate(board[-1]) if cell == "W") - - return board, candidates - - -def valid(board, r, c): - return 0 <= r < len(board) and 0 <= c < len(board[0]) - - -# all capturing moves white piece can make -def capturing_moves(board, r, c) -> list[tuple[int, int]]: - if not valid(board, r, c): - return [] - - moves = [] - - for dr, dc in [(-1, -1), (1, 1), (-1, 1), (1, -1)]: - if ( - valid(board, r + 2 * dr, c + 2 * dc) - and board[r + dr][c + dc] == "B" - and board[r + 2 * dr][c + 2 * dc] not in "BW" - ): - moves.append((dr, dc)) - - return moves - - -def max_candidate_captures(board, r, c) -> int: - max_captures = 0 - - for dr, dc in capturing_moves(board, r, c): - # place - board[r][c] = "." - board[r + dr][c + dc] = "." - board[r + dr * 2][c + dc * 2] = "W" - - ans = max_candidate_captures(board, r + dr * 2, c + dc * 2) - max_captures = max(max_captures, 1 + ans) - - # unplace - board[r + dr * 2][c + dc * 2] = "." - board[r][c] = "W" - board[r + dr][c + dc] = "B" - - return max_captures - - -def max_captures(board, candidates: list[tuple[int, int]]) -> int: - max_captures = 0 - - for r, c in candidates: - max_captures = max(max_captures, max_candidate_captures(board, r, c)) - - return max_captures - - -def solve() -> None: - T = int(input()) - - while T: - board, candidates = parse_board() - print(max_captures(board, candidates)) - T -= 1 - - -def main() -> None: - solve() - - -if __name__ == "__main__": - main() diff --git a/kattis/23-9-24/contest.md b/kattis/23-9-24/contest.md deleted file mode 100644 index 065a704..0000000 --- a/kattis/23-9-24/contest.md +++ /dev/null @@ -1,3 +0,0 @@ -# contest 2 - -https://open.kattis.com/contests/wrrf23 diff --git a/kattis/23-9-24/d/input.txt b/kattis/23-9-24/d/input.txt deleted file mode 100644 index b188259..0000000 --- a/kattis/23-9-24/d/input.txt +++ /dev/null @@ -1 +0,0 @@ -(2+(2*2)+2) diff --git a/kattis/23-9-24/d/solution.py b/kattis/23-9-24/d/solution.py deleted file mode 100644 index 68054c9..0000000 --- a/kattis/23-9-24/d/solution.py +++ /dev/null @@ -1,46 +0,0 @@ -def solve(equation: str) -> None: - stack = [] - paren_pairs = [] - - for i, token in enumerate(equation): - if token == "(": - stack.append([i, None]) - elif token == ")": - l, r = stack.pop() - r = i - paren_pairs.append((l, r)) - - P = [[]] - - for paren_pair in paren_pairs: - P.extend([[paren_pair] + p for p in P]) - - def format(permutation): - output = list(equation) - - for l, r in permutation: - output[l] = None - output[r] = None - - return "".join(filter(lambda token: token, output)) - - seen = set() - ans = [] - for permutation in P[1:]: - output = format(permutation) - if output not in seen: - seen.add(output) - ans.append(output) - - for x in sorted(ans): - print(x) - - -def main() -> None: - equation = input() - - solve(equation) - - -if __name__ == "__main__": - main() diff --git a/kattis/23-9-24/e/solution.py b/kattis/23-9-24/e/solution.py deleted file mode 100644 index 32811c7..0000000 --- a/kattis/23-9-24/e/solution.py +++ /dev/null @@ -1,22 +0,0 @@ -ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_." - -character_to_index = {c: i for i, c in enumerate(ALPHABET)} -index_to_character = {i: c for i, c in enumerate(ALPHABET)} - -while line := input(): - split = line.split() - - if len(split) == 1: - break - - k, string = int(split[0]), split[1] - - backwards = string[::-1] - - ans: list[str] = [] - - for letter in backwards: - index = character_to_index[letter] - ans.append(index_to_character[(index + k) % len(ALPHABET)]) - - print("".join(ans)) diff --git a/kattis/23-9-24/f/input.txt b/kattis/23-9-24/f/input.txt deleted file mode 100644 index 35b50fd..0000000 --- a/kattis/23-9-24/f/input.txt +++ /dev/null @@ -1,6 +0,0 @@ -Will Smith -Agent Smith -Peter Pan -Micky Mouse -Minnie Mouse -Peter Gunn diff --git a/kattis/23-9-24/f/solution.py b/kattis/23-9-24/f/solution.py deleted file mode 100644 index dbfae37..0000000 --- a/kattis/23-9-24/f/solution.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys -from collections import Counter - - -def solve() -> None: - counter: Counter[str] = Counter() - - ans = [] - - lines = sys.stdin.readlines() - for line in lines: - first, last = line.split() - - counter[first] += 1 - - ans.append((last, first)) - - ans.sort() - - for last, first in ans: - if counter[first] > 1: - print(f"{first} {last}") - else: - print(first) - - -def main() -> None: - solve() - - -if __name__ == "__main__": - main() diff --git a/kattis/25-2-2025/.clang-format b/kattis/25-2-2025/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/kattis/25-2-2025/.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/readme.md b/readme.md new file mode 100644 index 0000000..9f29833 --- /dev/null +++ b/readme.md @@ -0,0 +1,5 @@ +# competitive programming + +an archive of competitive programming code + +codeforces account: [frozenpipe](https://codeforces.com/profile/frozenpipe) diff --git a/usaco/bronze/simulation/.clang-format b/usaco/bronze/simulation/.clang-format new file mode 100644 index 0000000..e7350c4 --- /dev/null +++ b/usaco/bronze/simulation/.clang-format @@ -0,0 +1,9 @@ +BasedOnStyle: Google +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortCompoundRequirementOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLambdasOnASingleLine: false +AllowShortLoopsOnASingleLine: false