diff --git a/codeforces/957/f.cc b/codeforces/957/f.cc index ca8f3d6..93c90ad 100644 --- a/codeforces/957/f.cc +++ b/codeforces/957/f.cc @@ -85,8 +85,10 @@ void solve() { continue; vec nxt; for (auto i : I) { - if (i * number >= sz(used)) + if (i * number >= sz(used) || used[i * number]) continue; + nxt.pb(i * number); + used[i * number] = true; if (i * number == x) { ++ans; used.reset(); @@ -96,10 +98,6 @@ void solve() { nxt.pb(number); break; } - if (!used[i * number]) { - nxt.pb(i * number); - used[i * number] = true; - } } I.insert(I.end(), all(nxt)); } diff --git a/codeforces/957/f.out b/codeforces/957/f.out index ed47a51..b68f53a 100644 --- a/codeforces/957/f.out +++ b/codeforces/957/f.out @@ -8,4 +8,4 @@ 3 [code]: 0 -[time]: 11.9431 ms +[time]: 4.93455 ms \ No newline at end of file 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/11-02-2025/.clangd b/kattis/11-02-2025/.clangd new file mode 100644 index 0000000..4fab872 --- /dev/null +++ b/kattis/11-02-2025/.clangd @@ -0,0 +1,8 @@ +CompileFlags: + Add: + - -std=c++23 + - -Wall + - -Wextra + - -Wpedantic + - -Wshadow + - -Wno-unknown-pragmas \ No newline at end of file diff --git a/kattis/11-02-2025/a.cc b/kattis/11-02-2025/a.cc new file mode 100644 index 0000000..4f17f9f --- /dev/null +++ b/kattis/11-02-2025/a.cc @@ -0,0 +1,130 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +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()); +} + +template +void pr(std::format_string fmt, Args&&... args) { + std::print(fmt, std::forward(args)...); +} + +template +void pr(std::format_string fmt) { + std::print(fmt); +} + +template +void prln(std::format_string fmt, Args&&... args) { + std::println(fmt, std::forward(args)...); +} + +template +void prln(std::format_string fmt) { + std::println(fmt); +} + +void prln() { + std::println(); +} + +void prln(auto const& t) { + std::println("{}", t); +} + +using ll = long long; +using ld = long double; +template +using vec = std::vector; + +#define ff first +#define ss second +#define eb emplace_back +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +// }}} + +void solve() { + int n; + cin >> n; + vec, 5>> cards(n); + vec, 5>> bitsets(n); + vec> val_to_row(n, vec(3001, -1)); + + for (int i = 0; i < n; ++i) { + for (int j = 0; j < 5; ++j) { + for (auto& value : cards[i][j]) { + cin >> value; + val_to_row[i][value] = j; + bitsets[i][j][value] = true; + } + } + } + + for (int i = 0; i < n; ++i) { + for (int j = i + 1; j < n; ++j) { + for (int k = 0; k < 5; ++k) { + for (auto& value : cards[i][k]) { + if (val_to_row[j][value] == -1) + continue; + auto both = bitsets[i][k] | bitsets[j][val_to_row[j][value]]; + both[value] = false; + + bool bad = false; + for (int c = 0; c < n && !bad; ++c) { + if (c == i || c == j) + continue; + for (int d = 0; d < 5; ++d) { + if ((bitsets[c][d] & both).count() == 5) { + bad = true; + break; + } + } + } + + if (!bad) { + cout << value << endl; + cout << i + 1 << ' ' << j + 1 << endl; + return; + } + } + } + } + } + + prln("no ties"); +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + + int t = 1; + // cin >> t; + + while (t--) { + solve(); + } + + return 0; +} +// }}} diff --git a/kattis/11-02-2025/a.in b/kattis/11-02-2025/a.in new file mode 100644 index 0000000..7144962 --- /dev/null +++ b/kattis/11-02-2025/a.in @@ -0,0 +1,12 @@ +2 +2189 2127 1451 982 835 +150 1130 779 1326 1149 +2697 2960 315 534 2537 +2750 1771 875 1702 430 +300 2657 2827 983 947 + +886 738 2569 1107 2758 +2795 173 1718 2294 1732 +1188 2273 2489 1251 2224 +431 1050 1764 1193 1566 +1194 1561 162 1673 2411 diff --git a/kattis/11-02-2025/a.out b/kattis/11-02-2025/a.out new file mode 100644 index 0000000..cb749f5 --- /dev/null +++ b/kattis/11-02-2025/a.out @@ -0,0 +1,3 @@ +no ties +[code]: 0 +[time]: 11.3895 ms diff --git a/kattis/11-02-2025/b.cc b/kattis/11-02-2025/b.cc new file mode 100644 index 0000000..e5a9066 --- /dev/null +++ b/kattis/11-02-2025/b.cc @@ -0,0 +1,95 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +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()); +} + +template +void pr(std::format_string fmt, Args &&...args) { + std::print(fmt, std::forward(args)...); +} + +template +void pr(std::format_string fmt) { + std::print(fmt); +} + +template +void prln(std::format_string fmt, Args &&...args) { + std::println(fmt, std::forward(args)...); +} + +template +void prln(std::format_string fmt) { + std::println(fmt); +} + +void prln() { + std::println(); +} + +void prln(auto const &t) { + std::println("{}", t); +} + +using ll = long long; +using ld = long double; +template +using vec = std::vector; + +#define ff first +#define ss second +#define eb emplace_back +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +// }}} + +auto lcm = [](int a, int b) { + return a * b; +}; + +void solve() { + int p, q, s; + cin >> p >> q >> s; + auto lcm = [](int a, int b) { + return a * b / __gcd(a, b); + }; + if (lcm(p, q) <= s) + prln("yes"); + else + prln("no"); + prln(); +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + + int t = 1; + + while (t--) { + solve(); + } + + return 0; +} +// }}} diff --git a/kattis/11-02-2025/b.in b/kattis/11-02-2025/b.in new file mode 100644 index 0000000..0924703 --- /dev/null +++ b/kattis/11-02-2025/b.in @@ -0,0 +1 @@ +2 5 20 diff --git a/kattis/11-02-2025/b.out b/kattis/11-02-2025/b.out new file mode 100644 index 0000000..029ffcd --- /dev/null +++ b/kattis/11-02-2025/b.out @@ -0,0 +1,5 @@ +yes + + +[code]: 0 +[time]: 3.85022 ms \ No newline at end of file diff --git a/kattis/11-02-2025/c.cc b/kattis/11-02-2025/c.cc new file mode 100644 index 0000000..46a0a46 --- /dev/null +++ b/kattis/11-02-2025/c.cc @@ -0,0 +1,84 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +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()); +} + + +template +void pr(std::format_string fmt, Args&&... args) { + std::print(fmt, std::forward(args)...); +} + +template +void pr(std::format_string fmt) { + std::print(fmt); +} + +template +void prln(std::format_string fmt, Args&&... args) { + std::println(fmt, std::forward(args)...); +} + +template +void prln(std::format_string fmt) { + std::println(fmt); +} + +void prln() { + std::println(); +} + +void prln(auto const& t) { + std::println("{}", t); +} + +using ll = long long; +using ld = long double; +template +using vec = std::vector; + +#define ff first +#define ss second +#define eb emplace_back +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +// }}} + +void solve() { + +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + + int t = 1; + cin >> t; + + while (t--) { + solve(); + } + + return 0; +} +// }}} diff --git a/kattis/11-02-2025/c.in b/kattis/11-02-2025/c.in new file mode 100644 index 0000000..e69de29 diff --git a/kattis/11-02-2025/c.out b/kattis/11-02-2025/c.out new file mode 100644 index 0000000..e69de29 diff --git a/kattis/11-02-2025/compile_flags.txt b/kattis/11-02-2025/compile_flags.txt new file mode 100644 index 0000000..0adea68 --- /dev/null +++ b/kattis/11-02-2025/compile_flags.txt @@ -0,0 +1,5 @@ +-std=c++23 +-Wall +-Wextra +-Wpedantic +-Wshadow diff --git a/kattis/11-02-2025/f.cc b/kattis/11-02-2025/f.cc new file mode 100644 index 0000000..3a5a698 --- /dev/null +++ b/kattis/11-02-2025/f.cc @@ -0,0 +1,105 @@ +#include // {{{ + +// https://codeforces.com/blog/entry/96344 + +#pragma GCC optimize("O2,unroll-loops") +#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") + +using namespace std; + +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()); +} + +template +void pr(std::format_string fmt, Args&&... args) { + std::print(fmt, std::forward(args)...); +} + +template +void pr(std::format_string fmt) { + std::print(fmt); +} + +template +void prln(std::format_string fmt, Args&&... args) { + std::println(fmt, std::forward(args)...); +} + +template +void prln(std::format_string fmt) { + std::println(fmt); +} + +void prln() { + std::println(); +} + +void prln(auto const& t) { + std::println("{}", t); +} + +using ll = long long; +using ld = long double; +template +using vec = std::vector; + +#define ff first +#define ss second +#define eb emplace_back +#define pb push_back +#define all(x) (x).begin(), (x).end() +#define rall(x) (x).rbegin(), (x).rend() +// }}} + +void solve() { + int n; + cin >> n; + + string s; + cin >> s; + + int last = 0; + int ls = 0; + + for (int i = 0; i <= sz(s); ++i) { + if (s[i] == 'L') { + ++ls; + } else { + last = last + ls + 1; + cout << last << '\n'; + int x = last; + for (int j = 0; j < ls; ++j) { + --x; + cout << x << '\n'; + } + ls = 0; + } + } +} + +int main() { // {{{ + cin.tie(nullptr)->sync_with_stdio(false); + + int t = 1; + // cin >> t; + + while (t--) { + solve(); + } + + return 0; +} +// }} diff --git a/kattis/11-02-2025/f.in b/kattis/11-02-2025/f.in new file mode 100644 index 0000000..4e74daf --- /dev/null +++ b/kattis/11-02-2025/f.in @@ -0,0 +1,2 @@ +6 +RRRLL diff --git a/kattis/11-02-2025/f.out b/kattis/11-02-2025/f.out new file mode 100644 index 0000000..8f98d34 --- /dev/null +++ b/kattis/11-02-2025/f.out @@ -0,0 +1,9 @@ +1 +2 +3 +6 +5 +4 + +[code]: 0 +[time]: 16.3887 ms