cp-library

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

View the Project on GitHub qandori/cp-library

:heavy_check_mark: test/suffix_automaton_lcs.test.cpp

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

検証問題

依存ライブラリ

コード

#define PROBLEM "https://judge.yosupo.jp/problem/longest_common_substring"
#include "string/suffix_automaton.hpp"
#include "components/fast_io.hpp"

int main() {
	FastInput input;
	FastOutput output;
	std::string s, t;
	input.read(s), input.read(t);
	SuffixAutomaton automaton(s);
	auto match = automaton.longest_common_substring(t);
	output.write(match.text_pos), output.write(' ');
	output.write(match.text_pos + match.length), output.write(' ');
	output.write(match.query_pos), output.write(' ');
	output.println(match.query_pos + match.length);
}
Back to top page