From f52fdfca0bfa3189be0425789782c4f0e77c8efd Mon Sep 17 00:00:00 2001 From: usaco site Date: Tue, 20 Oct 2026 12:05:40 +0000 Subject: [PATCH] Start count-vowel-substrings-of-a-string --- .../count-vowel-substrings-of-a-string/.url | 1 + .../count-vowel-substrings-of-a-string.in | 3 + .../driver.h | 13 +++ .../main.cpp | 102 ++++++++++++++++++ .../problem.md | 45 ++++++++ .../tests/1.in | 1 + .../tests/1.out | 1 + .../tests/2.in | 1 + .../tests/2.out | 1 + .../tests/3.in | 1 + .../tests/3.out | 1 + 11 files changed, 170 insertions(+) create mode 100644 solving/count-vowel-substrings-of-a-string/.url create mode 100644 solving/count-vowel-substrings-of-a-string/count-vowel-substrings-of-a-string.in create mode 100644 solving/count-vowel-substrings-of-a-string/driver.h create mode 100644 solving/count-vowel-substrings-of-a-string/main.cpp create mode 100644 solving/count-vowel-substrings-of-a-string/problem.md create mode 100644 solving/count-vowel-substrings-of-a-string/tests/1.in create mode 100644 solving/count-vowel-substrings-of-a-string/tests/1.out create mode 100644 solving/count-vowel-substrings-of-a-string/tests/2.in create mode 100644 solving/count-vowel-substrings-of-a-string/tests/2.out create mode 100644 solving/count-vowel-substrings-of-a-string/tests/3.in create mode 100644 solving/count-vowel-substrings-of-a-string/tests/3.out diff --git a/solving/count-vowel-substrings-of-a-string/.url b/solving/count-vowel-substrings-of-a-string/.url new file mode 100644 index 0000000..32e790e --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/.url @@ -0,0 +1 @@ +https://leetcode.com/problems/count-vowel-substrings-of-a-string/ diff --git a/solving/count-vowel-substrings-of-a-string/count-vowel-substrings-of-a-string.in b/solving/count-vowel-substrings-of-a-string/count-vowel-substrings-of-a-string.in new file mode 100644 index 0000000..ca9ef3d --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/count-vowel-substrings-of-a-string.in @@ -0,0 +1,3 @@ +"aeiouu" +"unicornarihan" +"cuaieuouac" diff --git a/solving/count-vowel-substrings-of-a-string/driver.h b/solving/count-vowel-substrings-of-a-string/driver.h new file mode 100644 index 0000000..0df8534 --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/driver.h @@ -0,0 +1,13 @@ +// driver.h - generated by 'usaco new' from LeetCode's metadata (edit freely). +// Reads count-vowel-substrings-of-a-string.in in LeetCode's testcase format, cases back to back: +// one argument per line +// and writes one answer per case to count-vowel-substrings-of-a-string.out, formatted the way LeetCode +// shows its output. Parsing/printing helpers: leetcode.h. +int main() { + freopen("count-vowel-substrings-of-a-string.in", "r", stdin); + freopen("count-vowel-substrings-of-a-string.out", "w", stdout); + for (vector in; lc::read_case(in, 1);) { + auto word = lc::parse(in[0]); + cout << lc::show(Solution().countVowelSubstrings(word)) << '\n'; + } +} diff --git a/solving/count-vowel-substrings-of-a-string/main.cpp b/solving/count-vowel-substrings-of-a-string/main.cpp new file mode 100644 index 0000000..904aaa1 --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/main.cpp @@ -0,0 +1,102 @@ +#include +using namespace std; +#ifdef LOCAL // set by ./usaco builds only, so this is safe to submit as-is +#include "debugging.h" +#include "leetcode.h" // ListNode, TreeNode +#endif + + +// ----- TYPES ----- +typedef long long ll; +typedef pair pii; +typedef vector vi; + +// ----- FILE IO ----- +#define STDIN(filename) freopen(filename, "r", stdin) +#define STDOUT(filename) freopen(filename, "w", stdout) +#define FASTIO cin.tie(0)->sync_with_stdio(0) +#define STDIO(filename) \ + FASTIO; \ + string filenamee(filename); \ + STDIN((filenamee + ".in").c_str()); \ + STDOUT((filenamee + ".out").c_str()) +#define NL '\n' +#define CM ", " +#define SP " " + +// ----- FOR LOOPS ----- +#define F(i, L, R) for (int i = L; i < R; i++) +#define FE(i, L, R) for (int i = L; i <= R; i++) +#define FD(i, L, R) for (int i = L; i > R; i--) +#define FDE(i, L, R) for (int i = L; i >= R; i--) + +// ----- WEZ ----- +#define takeI(n) \ + int n; \ + cin >> n +#define takeII(n, m) \ + int n, m; \ + cin >> n >> m +#define takeIII(n, m, k) \ + int n, m, k; \ + cin >> n >> m >> k +#define takeL(n) \ + ll n; \ + cin >> n +#define takeS(s) \ + string s; \ + cin >> s +#define takeV(v, n) \ + vi v(n); \ + for (auto &x : v) \ + cin >> x +#define takeVL(v, n) \ + vector v(n); \ + for (auto &x : v) \ + cin >> x +#define whileZ \ + takeI(T); \ + while (T--) +// +// ----- MAX MIN ----- +#define REMAX(a, b) (a) = max((a), (b)) +#define REMIN(a, b) (a) = min((a), (b)) + +// ----- PAIRS ----- +#define fi first +#define se second + +// ----- OUTPUT ----- +#define YESNO(b) cout << ((b) ? "YES" : "NO") << NL + +// ----- DEBUG ----- (compiled out on the judge) +#ifdef LOCAL +#define DBG(vari) cerr << #vari << " = " << (vari) << endl +#define DBG2(a, b) cerr << #a "=" << (a) << CM << #b "=" << (b) << endl +#define printA(a, L, R) FE(i, L, R) cerr << a[i] << (i == R ? '\n' : ' ') +#define printV(a) printA(a, 0, SZ(a) - 1) +#else +#define DBG(vari) +#define DBG2(a, b) +#define printA(a, L, R) +#define printV(a) +#endif + +// ----- STL DS +#define ALL(c) (c).begin(), (c).end() +#define SZ(c) ((int)(c).size()) +#define SORT(c) sort(ALL(c)) +#define RSORT(c) sort(ALL(c), greater<>()) +#define UNIQ(c) SORT(c), (c).erase(unique(ALL(c)), (c).end()) +#define pb push_back + +class Solution { +public: + int countVowelSubstrings(string word) { + + } +}; + +#ifdef LOCAL // runs the examples; see driver.h +#include "driver.h" +#endif diff --git a/solving/count-vowel-substrings-of-a-string/problem.md b/solving/count-vowel-substrings-of-a-string/problem.md new file mode 100644 index 0000000..d0bf892 --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/problem.md @@ -0,0 +1,45 @@ +# 2062. Count Vowel Substrings of a String + +A **substring** is a contiguous (non-empty) sequence of characters within a string. + +A **vowel substring** is a substring that **only** consists of vowels (`'a'`, `'e'`, `'i'`, `'o'`, and `'u'`) and has **all five** vowels present in it. + +Given a string `word`, return *the number of **vowel substrings** in* `word`. + +**Example 1:** + +``` +Input: word = "aeiouu" +Output: 2 +Explanation: The vowel substrings of word are as follows (underlined): +- "aeiouu" +- "aeiouu" +``` + +**Example 2:** + +``` +Input: word = "unicornarihan" +Output: 0 +Explanation: Not all 5 vowels are present, so there are no vowel substrings. +``` + +**Example 3:** + +``` +Input: word = "cuaieuouac" +Output: 7 +Explanation: The vowel substrings of word are as follows (underlined): +- "cuaieuouac" +- "cuaieuouac" +- "cuaieuouac" +- "cuaieuouac" +- "cuaieuouac" +- "cuaieuouac" +- "cuaieuouac" +``` + +**Constraints:** + +- `1 <= word.length <= 100` +- `word` consists of lowercase English letters only. diff --git a/solving/count-vowel-substrings-of-a-string/tests/1.in b/solving/count-vowel-substrings-of-a-string/tests/1.in new file mode 100644 index 0000000..b5b4f2b --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/tests/1.in @@ -0,0 +1 @@ +"aeiouu" diff --git a/solving/count-vowel-substrings-of-a-string/tests/1.out b/solving/count-vowel-substrings-of-a-string/tests/1.out new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/tests/1.out @@ -0,0 +1 @@ +2 diff --git a/solving/count-vowel-substrings-of-a-string/tests/2.in b/solving/count-vowel-substrings-of-a-string/tests/2.in new file mode 100644 index 0000000..60b2f1c --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/tests/2.in @@ -0,0 +1 @@ +"unicornarihan" diff --git a/solving/count-vowel-substrings-of-a-string/tests/2.out b/solving/count-vowel-substrings-of-a-string/tests/2.out new file mode 100644 index 0000000..573541a --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/tests/2.out @@ -0,0 +1 @@ +0 diff --git a/solving/count-vowel-substrings-of-a-string/tests/3.in b/solving/count-vowel-substrings-of-a-string/tests/3.in new file mode 100644 index 0000000..6c197bb --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/tests/3.in @@ -0,0 +1 @@ +"cuaieuouac" diff --git a/solving/count-vowel-substrings-of-a-string/tests/3.out b/solving/count-vowel-substrings-of-a-string/tests/3.out new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/solving/count-vowel-substrings-of-a-string/tests/3.out @@ -0,0 +1 @@ +7