feat(codeforces): 855
This commit is contained in:
parent
a28174b99f
commit
d923953692
27 changed files with 916 additions and 0 deletions
86
codeforces/855/1800a.cc
Normal file
86
codeforces/855/1800a.cc
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T> constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T> constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
constexpr string meow{"meow"};
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 n;
|
||||||
|
cin >> n;
|
||||||
|
string s;
|
||||||
|
cin >> s;
|
||||||
|
|
||||||
|
u32 i = 0, j = 0;
|
||||||
|
|
||||||
|
while (j < meow.size() && i < n && tolower(s[i]) == meow[j]) {
|
||||||
|
while (i < n && tolower(s[i]) == meow[j])
|
||||||
|
++i;
|
||||||
|
++j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i == n && j == meow.size()) {
|
||||||
|
cout << "YES";
|
||||||
|
} else {
|
||||||
|
cout << "NO";
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
89
codeforces/855/1800b.cc
Normal file
89
codeforces/855/1800b.cc
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T> constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T> constexpr T MAX = std::numeric_limits<T>::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, k;
|
||||||
|
cin >> n >> k;
|
||||||
|
string s;
|
||||||
|
cin >> s;
|
||||||
|
vector<i32> f(26, 0);
|
||||||
|
|
||||||
|
u32 ans = 0;
|
||||||
|
for (auto letter : s) {
|
||||||
|
if (isupper(letter)) {
|
||||||
|
if (f[letter - 'a']++ < 0) {
|
||||||
|
++ans;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (f[letter]-- > 0) {
|
||||||
|
++ans;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 matches = 0;
|
||||||
|
// for (auto freq : f) {
|
||||||
|
// matches += freq / 2;
|
||||||
|
// }
|
||||||
|
|
||||||
|
cout << ans + min(k, matches) << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
66
codeforces/855/1800c1.cc
Normal file
66
codeforces/855/1800c1.cc
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
67
codeforces/855/1800c2.cc
Normal file
67
codeforces/855/1800c2.cc
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
73
codeforces/855/1800d.cc
Normal file
73
codeforces/855/1800d.cc
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T> constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T> constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
int n;
|
||||||
|
cin >> n;
|
||||||
|
string s;
|
||||||
|
cin >> s;
|
||||||
|
int ans = n - 1;
|
||||||
|
for (int i = 0; i < n - 2; ++i) {
|
||||||
|
ans -= s[i] == s[i + 2];
|
||||||
|
}
|
||||||
|
cout << ans << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
67
codeforces/855/1800e1.cc
Normal file
67
codeforces/855/1800e1.cc
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
95
codeforces/855/1800e2.cc
Normal file
95
codeforces/855/1800e2.cc
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T> constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T> constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
bitset<2 * 100000> seen;
|
||||||
|
void solve() {
|
||||||
|
seen.reset();
|
||||||
|
u32 n, k;
|
||||||
|
cin >> n >> k;
|
||||||
|
string s, t;
|
||||||
|
cin >> s >> t;
|
||||||
|
|
||||||
|
u32 ans = 0;
|
||||||
|
vector<u32> f(26, 0);
|
||||||
|
|
||||||
|
auto dfs = [&](auto &&self, i32 i) -> void {
|
||||||
|
if (i < 0 || i >= n || seen[i])
|
||||||
|
return;
|
||||||
|
seen[i] = true;
|
||||||
|
++f[s[i] - 'a'];
|
||||||
|
--f[t[i] - 'a'];
|
||||||
|
for (auto d : {i - k, i - k - 1, i + k, i + k + 1}) {
|
||||||
|
self(self, d);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
bool ok = true;
|
||||||
|
for (i32 i = 0; i < n && ok; ++i) {
|
||||||
|
if (!seen[i]) {
|
||||||
|
dfs(dfs, i);
|
||||||
|
ok &= count(f.begin(), f.end(), 0) == 26;
|
||||||
|
f.assign(26, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << (ok ? "YES" : "NO") << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
94
codeforces/855/1800f.cc
Normal file
94
codeforces/855/1800f.cc
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T> constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T> constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
vector<u32> parities(200000, 0);
|
||||||
|
vector<bitset<32>> present(200000);
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
u32 n;
|
||||||
|
cin >> n;
|
||||||
|
|
||||||
|
string s;
|
||||||
|
for (u32 i = 0; i < n; ++i) {
|
||||||
|
cin >> s;
|
||||||
|
for (auto c : s) {
|
||||||
|
parities[i] ^= 1 << (c - 'a');
|
||||||
|
present[i].set(c - 'a');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u64 ans = 0;
|
||||||
|
unordered_map<u32, u64> f;
|
||||||
|
|
||||||
|
for (u32 c = 0; c < 26; ++c) {
|
||||||
|
u32 mask = ((1 << 26) - 1) ^ (1 << c);
|
||||||
|
for (u32 i = 0; i < n; i++) {
|
||||||
|
if (present[i].test(c))
|
||||||
|
continue;
|
||||||
|
ans += f[parities[i] ^ mask];
|
||||||
|
++f[parities[i]];
|
||||||
|
}
|
||||||
|
f.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << ans << '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
67
codeforces/855/1800g.cc
Normal file
67
codeforces/855/1800g.cc
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
#include <bits/stdc++.h> // {{{
|
||||||
|
|
||||||
|
#include <version>
|
||||||
|
#ifdef __cpp_lib_ranges_enumerate
|
||||||
|
#include <ranges>
|
||||||
|
namespace rv = std::views;
|
||||||
|
namespace rs = std::ranges;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// https://codeforces.com/blog/entry/96344
|
||||||
|
|
||||||
|
#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 <typename T>
|
||||||
|
constexpr T MIN = std::numeric_limits<T>::min();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
constexpr T MAX = std::numeric_limits<T>::max();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef LOCAL
|
||||||
|
#define db(...) std::print(__VA_ARGS__)
|
||||||
|
#define dbln(...) std::println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define db(...)
|
||||||
|
#define dbln(...)
|
||||||
|
#endif
|
||||||
|
// }}}
|
||||||
|
|
||||||
|
void solve() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// }}}
|
||||||
15
codeforces/855/io/1800a.1.cpin
Normal file
15
codeforces/855/io/1800a.1.cpin
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
7
|
||||||
|
4
|
||||||
|
meOw
|
||||||
|
14
|
||||||
|
mMmeoOoWWWwwwW
|
||||||
|
3
|
||||||
|
mew
|
||||||
|
7
|
||||||
|
MmeEeUw
|
||||||
|
4
|
||||||
|
MEOW
|
||||||
|
6
|
||||||
|
MmyaVW
|
||||||
|
5
|
||||||
|
meowA
|
||||||
7
codeforces/855/io/1800a.1.cpout
Normal file
7
codeforces/855/io/1800a.1.cpout
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
NO
|
||||||
11
codeforces/855/io/1800b.1.cpin
Normal file
11
codeforces/855/io/1800b.1.cpin
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
5
|
||||||
|
11 2
|
||||||
|
aAaaBACacbE
|
||||||
|
2 2
|
||||||
|
ab
|
||||||
|
4 1
|
||||||
|
aaBB
|
||||||
|
6 0
|
||||||
|
abBAcC
|
||||||
|
5 3
|
||||||
|
cbccb
|
||||||
5
codeforces/855/io/1800b.1.cpout
Normal file
5
codeforces/855/io/1800b.1.cpout
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
5
|
||||||
|
0
|
||||||
|
1
|
||||||
|
3
|
||||||
|
2
|
||||||
11
codeforces/855/io/1800c1.1.cpin
Normal file
11
codeforces/855/io/1800c1.1.cpin
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
5
|
||||||
|
5
|
||||||
|
3 3 3 0 0
|
||||||
|
6
|
||||||
|
0 3 3 0 0 3
|
||||||
|
7
|
||||||
|
1 2 3 0 4 5 0
|
||||||
|
7
|
||||||
|
1 2 5 0 4 3 0
|
||||||
|
5
|
||||||
|
3 1 0 0 4
|
||||||
5
codeforces/855/io/1800c1.1.cpout
Normal file
5
codeforces/855/io/1800c1.1.cpout
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
6
|
||||||
|
6
|
||||||
|
8
|
||||||
|
9
|
||||||
|
4
|
||||||
11
codeforces/855/io/1800c2.1.cpin
Normal file
11
codeforces/855/io/1800c2.1.cpin
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
5
|
||||||
|
5
|
||||||
|
3 3 3 0 0
|
||||||
|
6
|
||||||
|
0 3 3 0 0 3
|
||||||
|
7
|
||||||
|
1 2 3 0 4 5 0
|
||||||
|
7
|
||||||
|
1 2 5 0 4 3 0
|
||||||
|
5
|
||||||
|
3 1 0 0 4
|
||||||
5
codeforces/855/io/1800c2.1.cpout
Normal file
5
codeforces/855/io/1800c2.1.cpout
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
6
|
||||||
|
6
|
||||||
|
8
|
||||||
|
9
|
||||||
|
4
|
||||||
15
codeforces/855/io/1800d.1.cpin
Normal file
15
codeforces/855/io/1800d.1.cpin
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
7
|
||||||
|
6
|
||||||
|
aaabcc
|
||||||
|
10
|
||||||
|
aaaaaaaaaa
|
||||||
|
6
|
||||||
|
abcdef
|
||||||
|
7
|
||||||
|
abacaba
|
||||||
|
6
|
||||||
|
cccfff
|
||||||
|
4
|
||||||
|
abba
|
||||||
|
5
|
||||||
|
ababa
|
||||||
7
codeforces/855/io/1800d.1.cpout
Normal file
7
codeforces/855/io/1800d.1.cpout
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
4
|
||||||
|
1
|
||||||
|
5
|
||||||
|
3
|
||||||
|
3
|
||||||
|
3
|
||||||
|
1
|
||||||
22
codeforces/855/io/1800e1.1.cpin
Normal file
22
codeforces/855/io/1800e1.1.cpin
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
7
|
||||||
|
6 3
|
||||||
|
talant
|
||||||
|
atltna
|
||||||
|
7 3
|
||||||
|
abacaba
|
||||||
|
aaaabbc
|
||||||
|
12 3
|
||||||
|
abracadabraa
|
||||||
|
avadakedavra
|
||||||
|
5 3
|
||||||
|
accio
|
||||||
|
cicao
|
||||||
|
5 3
|
||||||
|
lumos
|
||||||
|
molus
|
||||||
|
4 3
|
||||||
|
uwjt
|
||||||
|
twju
|
||||||
|
4 3
|
||||||
|
kvpx
|
||||||
|
vxpk
|
||||||
7
codeforces/855/io/1800e1.1.cpout
Normal file
7
codeforces/855/io/1800e1.1.cpout
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
NO
|
||||||
22
codeforces/855/io/1800e2.1.cpin
Normal file
22
codeforces/855/io/1800e2.1.cpin
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
7
|
||||||
|
6 3
|
||||||
|
talant
|
||||||
|
atltna
|
||||||
|
7 1
|
||||||
|
abacaba
|
||||||
|
aaaabbc
|
||||||
|
12 6
|
||||||
|
abracadabraa
|
||||||
|
avadakedavra
|
||||||
|
5 3
|
||||||
|
accio
|
||||||
|
cicao
|
||||||
|
5 4
|
||||||
|
lumos
|
||||||
|
molus
|
||||||
|
4 3
|
||||||
|
uwjt
|
||||||
|
twju
|
||||||
|
4 3
|
||||||
|
kvpx
|
||||||
|
vxpk
|
||||||
7
codeforces/855/io/1800e2.1.cpout
Normal file
7
codeforces/855/io/1800e2.1.cpout
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
YES
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
NO
|
||||||
11
codeforces/855/io/1800f.1.cpin
Normal file
11
codeforces/855/io/1800f.1.cpin
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
10
|
||||||
|
ftl
|
||||||
|
abcdefghijklmnopqrstuvwxy
|
||||||
|
abcdeffghijkllmnopqrsttuvwxy
|
||||||
|
ffftl
|
||||||
|
aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyy
|
||||||
|
thedevid
|
||||||
|
bcdefghhiiiijklmnopqrsuwxyz
|
||||||
|
gorillasilverback
|
||||||
|
abcdefg
|
||||||
|
ijklmnopqrstuvwxyz
|
||||||
1
codeforces/855/io/1800f.1.cpout
Normal file
1
codeforces/855/io/1800f.1.cpout
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
5
|
||||||
44
codeforces/855/io/1800g.1.cpin
Normal file
44
codeforces/855/io/1800g.1.cpin
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
6
|
||||||
|
6
|
||||||
|
1 5
|
||||||
|
1 6
|
||||||
|
1 2
|
||||||
|
2 3
|
||||||
|
2 4
|
||||||
|
7
|
||||||
|
1 5
|
||||||
|
1 3
|
||||||
|
3 6
|
||||||
|
1 4
|
||||||
|
4 7
|
||||||
|
4 2
|
||||||
|
9
|
||||||
|
1 2
|
||||||
|
2 4
|
||||||
|
2 3
|
||||||
|
3 5
|
||||||
|
1 7
|
||||||
|
7 6
|
||||||
|
7 8
|
||||||
|
8 9
|
||||||
|
10
|
||||||
|
2 9
|
||||||
|
9 10
|
||||||
|
2 3
|
||||||
|
6 7
|
||||||
|
4 3
|
||||||
|
1 2
|
||||||
|
3 8
|
||||||
|
2 5
|
||||||
|
6 5
|
||||||
|
10
|
||||||
|
3 2
|
||||||
|
8 10
|
||||||
|
9 7
|
||||||
|
4 2
|
||||||
|
8 2
|
||||||
|
2 1
|
||||||
|
4 5
|
||||||
|
6 5
|
||||||
|
5 7
|
||||||
|
1
|
||||||
6
codeforces/855/io/1800g.1.cpout
Normal file
6
codeforces/855/io/1800g.1.cpout
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
YES
|
||||||
|
NO
|
||||||
|
NO
|
||||||
|
YES
|
||||||
Loading…
Add table
Add a link
Reference in a new issue