-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from rainbou-kpr/rhstring
add rhstring
- Loading branch information
Showing
4 changed files
with
216 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <iterator> | ||
#include <type_traits> | ||
#include <utility> | ||
|
||
namespace detail { | ||
using std::begin, std::end; | ||
|
||
template <class T, class = void> | ||
struct is_range_impl : std::false_type {}; | ||
template <class T> | ||
struct is_range_impl<T, std::void_t<decltype(begin(std::declval<T&>()), end(std::declval<T&>()))>> : std::true_type {}; | ||
} // namespace detail | ||
|
||
template <class T> | ||
struct is_range : detail::is_range_impl<T>::type {}; | ||
template <class T> | ||
inline constexpr bool is_range_v = is_range<T>::value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#define PROBLEM "https://atcoder.jp/contests/abc331/tasks/abc331_f" | ||
|
||
#include <iostream> | ||
|
||
#include "../cpp/rolling-hash.hpp" | ||
#include "../cpp/segtree.hpp" | ||
|
||
RollingHash rh; | ||
struct E { | ||
RHString operator()() const { return RHString(rh); } | ||
}; | ||
|
||
int main() { | ||
int N, Q; | ||
std::string S; | ||
std::cin >> N >> Q >> S; | ||
std::vector<RHString> init; | ||
init.reserve(N); | ||
for (char c : S) { | ||
init.emplace_back(rh, c); | ||
} | ||
StaticSegTree<RHString, std::plus<RHString>, E> seg(init); | ||
while (Q--) { | ||
int q; | ||
std::cin >> q; | ||
if (q == 1) { | ||
int x; | ||
char c; | ||
std::cin >> x >> c; | ||
seg.set(x - 1, RHString(rh, c)); | ||
} else { | ||
int L, R; | ||
std::cin >> L >> R; | ||
std::cout << (seg.prod(L - 1, R).is_palindrome() ? "Yes" : "No") << std::endl; | ||
} | ||
} | ||
} |