diff --git a/codeforces/.clang-format b/codeforces/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/725/.clang-format b/codeforces/725/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/725/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/725/a.cc b/codeforces/725/a.cc new file mode 100644 index 0000000..4af7488 --- /dev/null +++ b/codeforces/725/a.cc @@ -0,0 +1,68 @@ +#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/.clang-format b/codeforces/731/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/731/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/731/a.cc b/codeforces/731/a.cc new file mode 100644 index 0000000..7eee3c5 --- /dev/null +++ b/codeforces/731/a.cc @@ -0,0 +1,69 @@ +#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/.clang-format b/codeforces/734/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/734/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/734/a.cc b/codeforces/734/a.cc new file mode 100644 index 0000000..904c9f1 --- /dev/null +++ b/codeforces/734/a.cc @@ -0,0 +1,65 @@ +#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/.clang-format b/codeforces/739/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/739/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/739/a.cc b/codeforces/739/a.cc new file mode 100644 index 0000000..43272b9 --- /dev/null +++ b/codeforces/739/a.cc @@ -0,0 +1,70 @@ +#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/.clang-format b/codeforces/744/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/744/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/744/a.cc b/codeforces/744/a.cc new file mode 100644 index 0000000..458dda6 --- /dev/null +++ b/codeforces/744/a.cc @@ -0,0 +1,70 @@ +#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/.clang-format b/codeforces/748/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/748/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/748/a.cc b/codeforces/748/a.cc new file mode 100644 index 0000000..03923a1 --- /dev/null +++ b/codeforces/748/a.cc @@ -0,0 +1,65 @@ +#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/.clang-format b/codeforces/753/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/753/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/753/a.cc b/codeforces/753/a.cc new file mode 100644 index 0000000..fe30e22 --- /dev/null +++ b/codeforces/753/a.cc @@ -0,0 +1,73 @@ +#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/.clang-format b/codeforces/756/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/756/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/756/a.cc b/codeforces/756/a.cc new file mode 100644 index 0000000..b4c1e93 --- /dev/null +++ b/codeforces/756/a.cc @@ -0,0 +1,76 @@ +#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/.clang-format b/codeforces/760/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/760/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/760/a.cc b/codeforces/760/a.cc new file mode 100644 index 0000000..df261aa --- /dev/null +++ b/codeforces/760/a.cc @@ -0,0 +1,65 @@ +#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/764/.clang-format b/codeforces/764/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/764/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/764/a.cc b/codeforces/764/a.cc new file mode 100644 index 0000000..443625f --- /dev/null +++ b/codeforces/764/a.cc @@ -0,0 +1,65 @@ +#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/.clang-format b/codeforces/776/.clang-format new file mode 100644 index 0000000..59cd6f1 --- /dev/null +++ b/codeforces/776/.clang-format @@ -0,0 +1,17 @@ +BasedOnStyle: LLVM +IndentWidth: 2 +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/776/a.cc b/codeforces/776/a.cc new file mode 100644 index 0000000..7bd90b5 --- /dev/null +++ b/codeforces/776/a.cc @@ -0,0 +1,72 @@ +#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/811/a.cc b/codeforces/811/a.cc index b9e0a60..44fd9d6 100644 --- a/codeforces/811/a.cc +++ b/codeforces/811/a.cc @@ -39,35 +39,21 @@ constexpr T MAX = std::numeric_limits::max(); // }}} void solve() { - i32 n, H, M; + i32 n, H, M, h, m; cin >> n >> H >> M; - pair A{H,M}; - - vector> alarms(n); - for (auto& e : alarms) { - cin >> e.first >> e.second; - } - - sort(begin(alarms), end(alarms)); - - i32 ans = 0; + i32 ans = 24 * 60; for (i32 i = 0; i < n; ++i) { - auto& alarm = alarms[i]; - if (alarm >= A) { - ans = i; - break; + cin >> h >> m; + i32 diff = h * 60 + m - (H * 60 + M); + if (diff < 0) { + diff += 24 * 60; } + ans = min(ans, diff); } - auto& alarm = alarms[ans]; - i32 diff = abs(alarm.first * 60 + alarm.second - (A.first * 60 + A.second)); - if (alarm < A) { - diff = 24 * 60 - diff; - } - - println("{} {}", diff / 60, diff % 60); + println("{} {}", ans / 60, ans % 60); } int main() { // {{{