From 7aacde99f4705356a5822b794435f365beb11482 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 7 Jan 2025 00:54:22 -0600 Subject: [PATCH] initial commit --- codeforces/991/a.cc | 45 ++++++++++++++++++++++++++++++++++++ codeforces/991/a.in | 22 ++++++++++++++++++ codeforces/991/a.out | 0 codeforces/991/b.cc | 54 ++++++++++++++++++++++++++++++++++++++++++++ codeforces/991/b.in | 17 ++++++++++++++ codeforces/991/b.out | 8 +++++++ codeforces/991/c.cc | 53 +++++++++++++++++++++++++++++++++++++++++++ codeforces/991/c.in | 10 ++++++++ codeforces/991/c.out | 9 ++++++++ usaco/blocks.cc | 48 +++++++++++++++++++++++++++++++++++++++ usaco/blocks.in | 4 ++++ usaco/blocks.out | 26 +++++++++++++++++++++ 12 files changed, 296 insertions(+) create mode 100644 codeforces/991/a.cc create mode 100644 codeforces/991/a.in create mode 100644 codeforces/991/a.out create mode 100644 codeforces/991/b.cc create mode 100644 codeforces/991/b.in create mode 100644 codeforces/991/b.out create mode 100644 codeforces/991/c.cc create mode 100644 codeforces/991/c.in create mode 100644 codeforces/991/c.out create mode 100644 usaco/blocks.cc create mode 100644 usaco/blocks.in create mode 100644 usaco/blocks.out diff --git a/codeforces/991/a.cc b/codeforces/991/a.cc new file mode 100644 index 0000000..8955ec7 --- /dev/null +++ b/codeforces/991/a.cc @@ -0,0 +1,45 @@ +#include +using namespace std; + +#define all(x) (x).begin(), (x).end() +#define sz(x) static_cast((x).size()) +#define FOR(x) for (size_t i = 0; i < (x).size(); ++i) + +#ifdef LOCAL +#define dbg(x) cerr << #x << " = " << (x) << '\n' +#else +#define dbg(x) +#endif + +void solve() { + int n, m; + cin >> n >> m; + size_t length = 0, words = 0; + bool order = true; + string s; + for (size_t i = 0; i < n; ++i) { + cin >> s; + if (length + s.size() <= m && order) { + dbg(m); + length += s.size(); + ++words; + } else { + order = false; + } + } + cout << words << '\n'; +} + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + int t; + cin >> t; + + while (t--) { + solve(); + } + + return 0; +} diff --git a/codeforces/991/a.in b/codeforces/991/a.in new file mode 100644 index 0000000..75e5811 --- /dev/null +++ b/codeforces/991/a.in @@ -0,0 +1,22 @@ +5 +3 1 +a +b +c +2 9 +alpha +beta +4 12 +hello +world +and +codeforces +3 2 +ab +c +d +3 2 +abc +ab +a + diff --git a/codeforces/991/a.out b/codeforces/991/a.out new file mode 100644 index 0000000..e69de29 diff --git a/codeforces/991/b.cc b/codeforces/991/b.cc new file mode 100644 index 0000000..0d14421 --- /dev/null +++ b/codeforces/991/b.cc @@ -0,0 +1,54 @@ +#include +using namespace std; + +#define all(x) (x).begin(), (x).end() +#define sz(x) static_cast((x).size()) +#define FOR(x) for (size_t i = 0; i < (x).size(); ++i) +#define FORI(x) for (size_t i = 0; i < (x); ++i) + +#ifdef LOCAL +#define dbg(x) cerr << #x << " = " << (x) << '\n' +#else +#define dbg(x) +#endif + +void solve() { + int n; + cin >> n; + vector a(n); + + int total = 0; + FOR(a) { + int x; + cin >> x; + a[i] = x; + total += x; + } + + long long odds = 0, evens = 0; + for (int i = 0; i < n; i++) { + (i & 1 ? odds : evens) += a[i]; + } + int odd_count = n >> 1, even_count = (n >> 1) + (n & 1); + + if (odds % odd_count == 0 && evens % even_count == 0 && + odds / odd_count == evens / even_count) { + cout << "YES\n"; + } else { + cout << "NO\n"; + } +} + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + int t; + cin >> t; + + while (t--) { + solve(); + } + + return 0; +} diff --git a/codeforces/991/b.in b/codeforces/991/b.in new file mode 100644 index 0000000..5199f66 --- /dev/null +++ b/codeforces/991/b.in @@ -0,0 +1,17 @@ +8 +3 +3 2 1 +3 +1 1 3 +4 +1 2 5 4 +4 +1 6 6 1 +5 +6 2 1 4 2 +4 +1 4 2 1 +5 +3 1 2 1 3 +3 +2 4 2 diff --git a/codeforces/991/b.out b/codeforces/991/b.out new file mode 100644 index 0000000..c5e7307 --- /dev/null +++ b/codeforces/991/b.out @@ -0,0 +1,8 @@ +YES +NO +YES +NO +YES +NO +NO +NO diff --git a/codeforces/991/c.cc b/codeforces/991/c.cc new file mode 100644 index 0000000..da95048 --- /dev/null +++ b/codeforces/991/c.cc @@ -0,0 +1,53 @@ +#include +using namespace std; + +#define all(x) (x).begin(), (x).end() +#define sz(x) static_cast((x).size()) +#define FOR(x) for (size_t i = 0; i < (x).size(); ++i) + +#ifdef LOCAL +#define dbg(x) cerr << #x << " = " << (x) << '\n' +#else +#define dbg(x) +#endif + +void solve() { + string n; + cin >> n; + + long long total = 0, twos = 0, threes = 0; + + for (char c : n) { + int digit = c - '0'; + if (digit == 2) + ++twos; + else if (digit == 3) + ++threes; + total += digit; + } + + for (long long i = 0; i < std::min(10LL, twos + 1); ++i) { + for (long long j = 0; j < std::min(10LL, threes + 1); ++j) { + if ((total + i * 2 + j * 6) % 9 == 0) { + cout << "YES\n"; + return; + } + } + } + + cout << "NO\n"; +} + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + int t; + cin >> t; + + while (t--) { + solve(); + } + + return 0; +} diff --git a/codeforces/991/c.in b/codeforces/991/c.in new file mode 100644 index 0000000..694f883 --- /dev/null +++ b/codeforces/991/c.in @@ -0,0 +1,10 @@ +9 +123 +322 +333333333333 +9997 +5472778912773 +1234567890 +23 +33 +52254522632 diff --git a/codeforces/991/c.out b/codeforces/991/c.out new file mode 100644 index 0000000..da7801d --- /dev/null +++ b/codeforces/991/c.out @@ -0,0 +1,9 @@ +NO +YES +YES +NO +NO +YES +NO +YES +YES diff --git a/usaco/blocks.cc b/usaco/blocks.cc new file mode 100644 index 0000000..efb74ec --- /dev/null +++ b/usaco/blocks.cc @@ -0,0 +1,48 @@ +#include +using namespace std; + +#define all(x) (x).begin(), (x).end() +#define sz(x) static_cast((x).size()) +#define FOR(x) for (size_t i = 0; i < (x).size(); ++i) + +#ifndef LOCAL +#define dbg(x) cerr << #x << " = " << (x) << '\n' +#else +#define dbg(x) +#endif + +#define PROBLEM_NAME "blocks" + +void solve() { + int N; + cin >> N; + vector ans(26, 0); + + for(int i = 0; i < N; ++i) { + string left, right; + cin >> left >> right; + vector count_left(26, 0); + for(char c : left) count_left[c - 'a']++; + vector count_right(26, 0); + for(char c : right) count_right[c - 'a']++; + for(int j = 0; j < 26; ++j) { + ans[j] += max(count_left[j], count_right[j]); + } + } + + for(int count : ans) { + cout << count << '\n'; + } +} + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + + freopen(PROBLEM_NAME ".in", "r", stdin); + freopen(PROBLEM_NAME ".out", "w", stdout); + + solve(); + + return 0; +} diff --git a/usaco/blocks.in b/usaco/blocks.in new file mode 100644 index 0000000..d0be452 --- /dev/null +++ b/usaco/blocks.in @@ -0,0 +1,4 @@ +3 +fox box +dog cat +car bus diff --git a/usaco/blocks.out b/usaco/blocks.out new file mode 100644 index 0000000..52ed73e --- /dev/null +++ b/usaco/blocks.out @@ -0,0 +1,26 @@ +2 +2 +2 +1 +0 +1 +1 +0 +0 +0 +0 +0 +0 +0 +2 +0 +0 +1 +1 +1 +1 +0 +0 +1 +0 +0