cp-library

競技プログラミング用 C++ ライブラリ

View the Project on GitHub qandori/cp-library

:heavy_check_mark: test/rolling_hash.test.cpp

test/rolling_hash.test.cpp · GitHub で見る

検証問題

依存ライブラリ

コード

#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_14_B"
#include "../string/rolling_hash.hpp"
#include <iostream>
#include <string>

int main() {
	std::cin.tie(nullptr)->sync_with_stdio(false);
	std::string text, pattern;
	std::cin >> text >> pattern;
	RollingHash hash(text), target(pattern);
	for (int i = 0; i + target.size() <= hash.size(); ++i)
		if (hash.get(i, i + target.size()) == target.get()) std::cout << i << '\n';
}
Back to top page