시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 61 | 42 | 39 | 67.241% |
Bessie's friend Jessie wanted to enter a programming contest. "What are the tasks like?" she asked.
Bessie, known to be knowledgeable about so many things, said "Here is a typical problem that folks solve early in their competitive career. See if you can solve it."
Perhaps you can solve it, too.
You are given two sequences of integers, S1 and S2. S1 has length L1 (1 <= L1 <= 180) and S2 has length L2 (1 <= L2 <= 180). Your job is to print out the length of the longest contiguous subsequence of numbers common to both S1 and S2. Ordered sequence S1 has elements S1_1, S1_2, ..., S1_L1 (-100 <= S1_i <= 100); S2 has elements S2_i (-100 <= S2_i <= 100).
A contiguous subsequence is a consecutive run of numbers in that sequence. The subsequences of 1 2 3 1 are: the empty sequence, "1", "1 2", "1 2 3", "1 2 3 1", "2", "2 3", "2 3 1", "3", "3 1", and a repeat occurrence of "1".
10 12 1 1 1 3 2 3 3 3 4 5 1 1 1 1 3 2 3 3 4 4 5 -8
7
Corresponds to the contiguous subsequence 1,1,1,3,2,3,3.
Olympiad > USA Computing Olympiad > 2009-2010 Season > USACO March 2010 Contest > Bronze 4번
Olympiad > USA Computing Olympiad > 2009-2010 Season > USACO Holiday Bonus 2010 Contest > Gold 1번