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/817/.clangd b/codeforces/817/.clangd new file mode 100644 index 0000000..20950b9 --- /dev/null +++ b/codeforces/817/.clangd @@ -0,0 +1,41 @@ +CompileFlags: + Add: + -O2 + -Wall + -Wextra + -Wpedantic + -Wshadow + -Wformat=2 + -Wfloat-equal + -Wlogical-op + -Wshift-overflow=2 + -Wnon-virtual-dtor + -Wold-style-cast + -Wcast-qual + -Wuseless-cast + -Wno-sign-promotion + -Wcast-align + -Wunused + -Woverloaded-virtual + -Wconversion + -Wsign-conversion + -Wmisleading-indentation + -Wduplicated-cond + -Wduplicated-branches + -Wlogical-op + -Wnull-dereference + -Wformat=2 + -Wformat-overflow + -Wformat-truncation + -Wdouble-promotion + -Wundef + -DLOCAL + -Wno-unknown-pragmas + -std=c++23 + -std=c++23 + -std=c++23 + -std=c++23 + -std=c++23 + -std=c++23 + -std=c++23 + -std=c++23 diff --git a/codeforces/817/a.cc b/codeforces/817/a.cc new file mode 100644 index 0000000..a427868 --- /dev/null +++ b/codeforces/817/a.cc @@ -0,0 +1,104 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#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; + + sort(all(s)); + string timur = "Timur"; + sort(all(timur)); + + if (n != timur.size()) { + NO(); + return; + } + + for (u32 i = 0; i < n; ++i) { + if (s[i] == 'T') { + if (timur[i] != 'T') { + NO(); + return; + } + } else { + if (s[i] != timur[i]) { + NO(); + return; + } + } + } + YES(); +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + u32 tc = 1; + cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/817/b.cc b/codeforces/817/b.cc new file mode 100644 index 0000000..5fa1f75 --- /dev/null +++ b/codeforces/817/b.cc @@ -0,0 +1,90 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#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 a, b; + cin >> a >> b; + + for (u32 i = 0; i < n; ++i) { + if (a[i] == b[i] || + (a[i] == 'G' || a[i] == 'B') && (b[i] == 'G' || b[i] == 'B')) { + continue; + } + NO(); + return; + } + YES(); +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + u32 tc = 1; + cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/817/c.cc b/codeforces/817/c.cc new file mode 100644 index 0000000..0e3efce --- /dev/null +++ b/codeforces/817/c.cc @@ -0,0 +1,103 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#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; + + vec> words(3); + map count; + + string word; + for (u32 i = 0; i < 3; ++i) { + for (u32 j = 0; j < n; ++j) { + cin >> word; + words[i].insert(word); + ++count[word]; + } + } + + for (u32 i = 0; i < 3; ++i) { + u32 points = 0; + for (auto& w : words[i]) { + u32 x = (u32)words[0].contains(w) + words[1].contains(w) + + words[2].contains(w); + if (x == 2) + ++points; + else if (x == 1) + points += 3; + } + cout << points << " \n"[i == 2]; + } +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + u32 tc = 1; + cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/817/compile_flags.txt b/codeforces/817/compile_flags.txt new file mode 100644 index 0000000..5373b01 --- /dev/null +++ b/codeforces/817/compile_flags.txt @@ -0,0 +1,30 @@ +-O2 +-Wall +-Wextra +-Wpedantic +-Wshadow +-Wformat=2 +-Wfloat-equal +-Wlogical-op +-Wshift-overflow=2 +-Wnon-virtual-dtor +-Wold-style-cast +-Wcast-qual +-Wuseless-cast +-Wno-sign-promotion +-Wcast-align +-Wunused +-Woverloaded-virtual +-Wconversion +-Wmisleading-indentation +-Wduplicated-cond +-Wduplicated-branches +-Wlogical-op +-Wnull-dereference +-Wformat=2 +-Wformat-overflow +-Wformat-truncation +-Wdouble-promotion +-Wundef +-DLOCAL +-std=c++23 diff --git a/codeforces/817/d.cc b/codeforces/817/d.cc new file mode 100644 index 0000000..25b53a7 --- /dev/null +++ b/codeforces/817/d.cc @@ -0,0 +1,115 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#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; + + vec deltas; + u64 initial_value = 0; + for (u32 i = 0; i < n; ++i) { + if (s[i] == 'L') { + u64 dont = i; + initial_value += dont; + u64 turn = n - i - 1; + + if (turn > dont) { + deltas.emplace_back(turn - dont); + } + } else { + u64 dont = n - i - 1; + initial_value += dont; + u64 turn = i; + + if (turn > dont) { + deltas.emplace_back(turn - dont); + } + } + } + + sort(rall(deltas)); + + u32 i = 0; + u64 total = initial_value; + for (u32 k = 1; k <= n; ++k) { + if (i < deltas.size()) { + total += deltas[i]; + ++i; + } + + cout << total << " \n"[k == n]; + } +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + u32 tc = 1; + cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/817/debug_flags.txt b/codeforces/817/debug_flags.txt new file mode 100644 index 0000000..62a0135 --- /dev/null +++ b/codeforces/817/debug_flags.txt @@ -0,0 +1,14 @@ +-g3 +-fsanitize=address,undefined +-fsanitize=float-divide-by-zero +-fsanitize=float-cast-overflow +-fno-sanitize-recover=all +-fstack-protector-all +-fstack-usage +-fno-omit-frame-pointer +-fno-inline +-ffunction-sections +-D_GLIBCXX_DEBUG +-D_GLIBCXX_DEBUG_PEDANTIC +-DLOCAL +-std=c++23 diff --git a/codeforces/817/e.cc b/codeforces/817/e.cc new file mode 100644 index 0000000..52a0100 --- /dev/null +++ b/codeforces/817/e.cc @@ -0,0 +1,101 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +void solve() { + u32 n, q; + cin >> n >> q; + + vec> prefix(1000 + 1, vec(1000 + 1, 0)); + + for (u32 i = 0; i < n; ++i) { + u64 h, w; + cin >> h >> w; + prefix[h][w] += h * w; + } + + for (u32 i = 1; i <= 1000; ++i) + for (u32 j = 1; j <= 1000; ++j) + prefix[i][j] += + prefix[i - 1][j] + prefix[i][j - 1] - prefix[i - 1][j - 1]; + + for (u32 i = 0; i < q; ++i) { + u32 hs, ws, hb, wb; + cin >> hs >> ws >> hb >> wb; + + u64 ans = prefix[hb - 1][wb - 1] - prefix[hs][wb - 1] - prefix[hb - 1][ws] + + prefix[hs][ws]; + + cout << ans << '\n'; + } +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + u32 tc = 1; + cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/817/f.cc b/codeforces/817/f.cc new file mode 100644 index 0000000..e9dda08 --- /dev/null +++ b/codeforces/817/f.cc @@ -0,0 +1,139 @@ +#include // {{{ + +#include + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#ifdef LOCAL +#define db(...) std::print(__VA_ARGS__) +#define dbln(...) std::println(__VA_ARGS__) +#else +#define db(...) +#define dbln(...) +#endif +// }}} + +bitset<50 * 50 + 1> visited; + +void solve() { + const i32 dr8[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; + const i32 dc8[8] = {-1, 0, 1, -1, 1, -1, 0, 1}; + u32 n, m; + cin >> n >> m; + vec g(n); + for (auto& s : g) + cin >> s; + vec> vis(n, vec(m, 0)); + bool ok = true; + for (i32 r = 0; r < (i32)n && ok; ++r) + for (i32 c = 0; c < (i32)m && ok; ++c) + if (g[r][c] == '*' && !vis[r][c]) { + vec> comp; + vec> q = {{r, c}}; + vis[r][c] = 1; + for (i32 qi = 0; qi < (i32)q.size(); ++qi) { + auto [x, y] = q[qi]; + comp.push_back({x, y}); + for (i32 d = 0; d < 8; ++d) { + i32 nx = x + dr8[d], ny = y + dc8[d]; + if (0 <= nx && nx < (i32)n && 0 <= ny && ny < (i32)m && + g[nx][ny] == '*' && !vis[nx][ny]) { + vis[nx][ny] = 1; + q.push_back({nx, ny}); + } + } + } + if (comp.size() != 3) { + ok = false; + break; + } + vec rows, cols; + for (auto [x, y] : comp) { + rows.push_back(x); + cols.push_back(y); + } + sort(rows.begin(), rows.end()); + rows.erase(unique(rows.begin(), rows.end()), rows.end()); + sort(cols.begin(), cols.end()); + cols.erase(unique(cols.begin(), cols.end()), cols.end()); + if (rows.size() != 2 || cols.size() != 2) { + ok = false; + break; + } + i32 cnt = 0; + for (i32 i = 0; i < 2; ++i) + for (i32 j = 0; j < 2; ++j) + for (auto [x, y] : comp) + if (x == rows[i] && y == cols[j]) + ++cnt; + if (cnt != 3) { + ok = false; + break; + } + } + if (ok) + YES(); + else + NO(); +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + u32 tc = 1; + cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/817/g.cc b/codeforces/817/g.cc new file mode 100644 index 0000000..8df51df --- /dev/null +++ b/codeforces/817/g.cc @@ -0,0 +1,110 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +using i32 = int32_t; +using u32 = uint32_t; +using i64 = int64_t; +using u64 = uint64_t; +using f64 = double; +using f128 = long double; + +#if __cplusplus >= 202002L +template +constexpr T MIN = std::numeric_limits::min(); + +template +constexpr T MAX = std::numeric_limits::max(); + +template +[[nodiscard]] static T sc(auto&& x) { + return static_cast(x); +} + +template +[[nodiscard]] static T sz(auto&& x) { + return static_cast(x.size()); +} +#endif + +static void NO() { + std::cout << "NO\n"; +} + +static void YES() { + std::cout << "YES\n"; +} + +template +using vec = std::vector; + +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +#define ff first +#define ss second + +#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; + + vec a(n); + for (u32 i = 0; i < n; i += 2) a[i] = i >> 1; + + u32 xe = 0; + for (u32 i = 0; i < n; i += 2) xe ^= a[i]; + + u32 odd = n >> 1; + if (!odd) { + for (u32 i = 0; i < n; ++i) cout << a[i] << " \n"[i == n - 1]; + return; + } + + const u32 BIG = 1u << 20; + u32 xo = 0; + for (u32 k = 0; k + 2 < odd; ++k) { + a[1 + 2 * k] = BIG + k; + xo ^= a[1 + 2 * k]; + } + + if (odd == 1) { + a[1] = BIG; + a[0] ^= xe ^ BIG; + } else { + u32 diff = xe ^ xo; + u32 p = BIG + odd - 2; + a[2 * odd - 3] = p; + a[2 * odd - 1] = p ^ diff; + } + + for (u32 i = 0; i < n; ++i) + cout << a[i] << " \n"[i == n - 1]; +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + cin.exceptions(cin.failbit); + + u32 tc = 1; + cin >> tc; + + for (u32 t = 0; t < tc; ++t) { + solve(); + } + + return 0; +} +// }}} diff --git a/codeforces/817/io/a.in b/codeforces/817/io/a.in new file mode 100644 index 0000000..d8e5471 --- /dev/null +++ b/codeforces/817/io/a.in @@ -0,0 +1,21 @@ +10 +5 +Timur +5 +miurT +5 +Trumi +5 +mriTu +5 +timur +4 +Timr +6 +Timuur +10 +codeforces +10 +TimurTimur +5 +TIMUR diff --git a/codeforces/817/io/a.out b/codeforces/817/io/a.out new file mode 100644 index 0000000..8908a5d --- /dev/null +++ b/codeforces/817/io/a.out @@ -0,0 +1,13 @@ +YES +YES +YES +YES +NO +NO +NO +NO +NO +NO + +[code]: 0 +[time]: 12.6028 ms \ No newline at end of file diff --git a/codeforces/817/io/b.in b/codeforces/817/io/b.in new file mode 100644 index 0000000..187ca0b --- /dev/null +++ b/codeforces/817/io/b.in @@ -0,0 +1,19 @@ +6 +2 +RG +RB +4 +GRBG +GBGB +5 +GGGGG +BBBBB +7 +BBBBBBB +RRRRRRR +8 +RGBRRGBR +RGGRRBGR +1 +G +G diff --git a/codeforces/817/io/b.out b/codeforces/817/io/b.out new file mode 100644 index 0000000..d3aa3cf --- /dev/null +++ b/codeforces/817/io/b.out @@ -0,0 +1,9 @@ +YES +NO +YES +NO +YES +YES + +[code]: 0 +[time]: 4.15921 ms \ No newline at end of file diff --git a/codeforces/817/io/c.in b/codeforces/817/io/c.in new file mode 100644 index 0000000..b10577d --- /dev/null +++ b/codeforces/817/io/c.in @@ -0,0 +1,13 @@ +3 +1 +abc +def +abc +3 +orz for qaq +qaq orz for +cod for ces +5 +iat roc hem ica lly +bac ter iol ogi sts +bac roc lly iol iat diff --git a/codeforces/817/io/c.out b/codeforces/817/io/c.out new file mode 100644 index 0000000..a741567 --- /dev/null +++ b/codeforces/817/io/c.out @@ -0,0 +1,6 @@ +1 3 1 +2 2 6 +9 11 5 + +[code]: 0 +[time]: 4.16636 ms \ No newline at end of file diff --git a/codeforces/817/io/d.in b/codeforces/817/io/d.in new file mode 100644 index 0000000..5446e5d --- /dev/null +++ b/codeforces/817/io/d.in @@ -0,0 +1,14 @@ +6 +3 +LLR +5 +LRRLL +1 +L +12 +LRRRLLLRLLRL +10 +LLLLLRRRRR +9 +LRLRLRLRL + diff --git a/codeforces/817/io/d.out b/codeforces/817/io/d.out new file mode 100644 index 0000000..e1cbfa9 --- /dev/null +++ b/codeforces/817/io/d.out @@ -0,0 +1,9 @@ +3 5 5 +16 16 16 16 16 +0 +86 95 98 101 102 102 102 102 102 102 102 102 +29 38 45 52 57 62 65 68 69 70 +44 50 54 56 56 56 56 56 56 + +[code]: 0 +[time]: 3.96514 ms \ No newline at end of file diff --git a/codeforces/817/io/e.in b/codeforces/817/io/e.in new file mode 100644 index 0000000..fe2ea42 --- /dev/null +++ b/codeforces/817/io/e.in @@ -0,0 +1,21 @@ +3 +2 1 +2 3 +3 2 +1 1 3 4 +5 5 +1 1 +2 2 +3 3 +4 4 +5 5 +3 3 6 6 +2 1 4 5 +1 1 2 10 +1 1 100 100 +1 1 3 3 +3 1 +999 999 +999 999 +999 998 +1 1 1000 1000 diff --git a/codeforces/817/io/e.out b/codeforces/817/io/e.out new file mode 100644 index 0000000..d53400b --- /dev/null +++ b/codeforces/817/io/e.out @@ -0,0 +1,10 @@ +6 +41 +9 +0 +54 +4 +2993004 + +[code]: 0 +[time]: 13.3142 ms \ No newline at end of file diff --git a/codeforces/817/io/f.in b/codeforces/817/io/f.in new file mode 100644 index 0000000..fd0be0c --- /dev/null +++ b/codeforces/817/io/f.in @@ -0,0 +1,49 @@ +10 +6 10 +........** +.**......* +..*..*.... +.....**... +...*.....* +..**....** +6 10 +....*...** +.**......* +..*..*.... +.....**... +...*.....* +..**....** +3 3 +... +*** +... +4 4 +.*.. +**.. +..** +..*. +5 4 +.*.. +**.. +.... +..** +..*. +3 2 +.* +** +*. +2 3 +*.. +.** +3 2 +.. +** +*. +3 3 +.** +*.* +**. +3 3 +..* +.** +..* diff --git a/codeforces/817/io/f.out b/codeforces/817/io/f.out new file mode 100644 index 0000000..e7cfad3 --- /dev/null +++ b/codeforces/817/io/f.out @@ -0,0 +1,13 @@ +YES +NO +NO +NO +YES +NO +NO +YES +NO +NO + +[code]: 0 +[time]: 4.43125 ms \ No newline at end of file diff --git a/codeforces/817/io/g.in b/codeforces/817/io/g.in new file mode 100644 index 0000000..50d3eda --- /dev/null +++ b/codeforces/817/io/g.in @@ -0,0 +1,9 @@ +7 +8 +3 +4 +5 +6 +7 +9 + diff --git a/codeforces/817/io/g.out b/codeforces/817/io/g.out new file mode 100644 index 0000000..fe2c84e --- /dev/null +++ b/codeforces/817/io/g.out @@ -0,0 +1,10 @@ +0 1048576 1 1048577 2 1048578 3 1048579 +1048577 1048576 1 +0 1048576 1 1048577 +0 1048576 1 1048579 2 +0 1048576 1 1048580 2 7 +0 1048576 1 1048580 2 4 3 +0 1048576 1 1048577 2 1048578 3 1048583 4 + +[code]: 0 +[time]: 4.62723 ms \ No newline at end of file diff --git a/codeforces/817/makefile b/codeforces/817/makefile new file mode 100644 index 0000000..3c50267 --- /dev/null +++ b/codeforces/817/makefile @@ -0,0 +1,30 @@ +.PHONY: run debug clean setup init + +VERSION ?= 20 + +SRC = $(word 2,$(MAKECMDGOALS)) + +.SILENT: + +run: + sh scripts/run.sh $(SRC) + +debug: + sh scripts/debug.sh $(SRC) + +clean: + rm -rf build/* + +setup: + test -d build || mkdir -p build + test -d io || mkdir -p io + test -d scripts || mkdir -p scripts + test -f .clang-format || cp $(HOME)/.config/cp-template/.clang-format . + test -f compile_flags.txt || cp $(HOME)/.config/cp-template/compile_flags.txt . && echo -std=c++$(VERSION) >>compile_flags.txt + test -f .clangd || cp $(HOME)/.config/cp-template/.clangd . && echo -e "\t\t-std=c++$(VERSION)" >>.clangd + +init: + make setup + +%: + @: diff --git a/codeforces/817/scripts/debug.sh b/codeforces/817/scripts/debug.sh new file mode 100644 index 0000000..2979422 --- /dev/null +++ b/codeforces/817/scripts/debug.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +. ./scripts/utils.sh + +SRC="$1" +BASE=$(basename "$SRC" .cc) +INPUT="${BASE}.in" +OUTPUT="${BASE}.out" +DBG_BIN="${BASE}.debug" + +test -d build || mkdir -p build +test -d io || mkdir -p io + +test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" +test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" + +test -f "io/$INPUT" || touch "io/$INPUT" +test -f "io/$OUTPUT" || touch "io/$OUTPUT" + +INPUT="io/$INPUT" +OUTPUT="io/$OUTPUT" +DBG_BIN="build/$DBG_BIN" + +compile_source "$SRC" "$DBG_BIN" "$OUTPUT" @debug_flags.txt +CODE=$? +test $CODE -gt 0 && exit $CODE + +execute_binary "$DBG_BIN" "$INPUT" "$OUTPUT" +exit $? diff --git a/codeforces/817/scripts/run.sh b/codeforces/817/scripts/run.sh new file mode 100644 index 0000000..ab9aa7d --- /dev/null +++ b/codeforces/817/scripts/run.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +. ./scripts/utils.sh + +SRC="$1" +BASE=$(basename "$SRC" .cc) +INPUT="${BASE}.in" +OUTPUT="${BASE}.out" +RUN_BIN="${BASE}.run" + +test -d build || mkdir -p build +test -d io || mkdir -p io + +test -f "$INPUT" && test ! -f "io/$INPUT" && mv "$INPUT" "io/" +test -f "$OUTPUT" && test ! -f "io/$OUTPUT" && mv "$OUTPUT" "io/" + +test -f "io/$INPUT" || touch "io/$INPUT" +test -f "io/$OUTPUT" || touch "io/$OUTPUT" + +INPUT="io/$INPUT" +OUTPUT="io/$OUTPUT" +RUN_BIN="build/$RUN_BIN" + +compile_source "$SRC" "$RUN_BIN" "$OUTPUT" "" +CODE=$? +test $CODE -gt 0 && exit $CODE + +execute_binary "$RUN_BIN" "$INPUT" "$OUTPUT" +exit $? diff --git a/codeforces/817/scripts/utils.sh b/codeforces/817/scripts/utils.sh new file mode 100644 index 0000000..e99b25b --- /dev/null +++ b/codeforces/817/scripts/utils.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +execute_binary() { + binary="$1" + input="$2" + output="$3" + + start=$(date '+%s.%N') + timeout 2s ./"$binary" <"$input" >"$output" 2>&1 + CODE=$? + end=$(date '+%s.%N') + truncate -s "$(head -n 1000 "$output" | wc -c)" "$output" + + if [ $CODE -ge 124 ]; then + MSG='' + case $CODE in + 124) MSG='TIMEOUT' ;; + 128) MSG='SIGILL' ;; + 130) MSG='SIGABRT' ;; + 131) MSG='SIGBUS' ;; + 136) MSG='SIGFPE' ;; + 135) MSG='SIGSEGV' ;; + 137) MSG='SIGPIPE' ;; + 139) MSG='SIGTERM' ;; + esac + [ $CODE -ne 124 ] && sed -i '$d' "$output" + test -n "$MSG" && printf '\n[code]: %s (%s)' "$CODE" "$MSG" >>"$output" + else + printf '\n[code]: %s' "$CODE" >>"$output" + fi + + printf '\n[time]: %s ms' "$(awk "BEGIN {print ($end - $start) * 1000}")" >>$output + return $CODE +} + +compile_source() { + src="$1" + bin="$2" + output="$3" + flags="$4" + + test -f "$bin" && rm "$bin" || true + g++ @compile_flags.txt $flags "$src" -o "$bin" 2>"$output" + CODE=$? + + if [ $CODE -gt 0 ]; then + printf '\n[code]: %s' "$CODE" >>"$output" + return $CODE + else + echo '' >"$output" + return 0 + fi +} diff --git a/codeforces/827/c.cc b/codeforces/827/c.cc index dbf580f..9752b8e 100644 --- a/codeforces/827/c.cc +++ b/codeforces/827/c.cc @@ -58,30 +58,16 @@ using vec = std::vector; // }}} void solve() { - vector grid(8); - for (auto& e : grid) - cin >> e; + string s; + for (u32 i = 0; i < 8; ++i) { + cin >> s; + if (s == "RRRRRRRR") { + cout << "R\n"; + return; + } + } - for (u32 r = 0; r < 8; ++r) { - bool good = true; - for (u32 c = 0; c < 8; ++c) { - good &= grid[r][c] == grid[r][0]; - } - if (good && grid[r][0] == 'R') { - cout << grid[r][0] << '\n'; - return; - } - } - for (u32 c = 0; c < 8; ++c) { - bool good = true; - for (u32 r = 0; r < 8; ++r) { - good &= grid[r][c] == grid[0][c]; - } - if (good && grid[0][c] == 'B') { - cout << grid[0][c] << '\n'; - return; - } - } + cout << "B\n"; } int main() { // {{{