Logo
(追記) (追記ここまで)

24261번 - Same Sum Subsequences 서브태스크스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.4 초 1024 MB176625135.664%

문제

You are given two positive integers n, m and two sequences of positive integers A and B. The sequence A consists of n elements, each one in the interval [1, m], while the sequence B consists of m elements, each one in the interval [1, n].

Write a program, which finds a nonempty subsequence of A and a nonempty subsequence of B, which have equal sums of elements.

Definition: For a sequence C = C0, C1, …, Cp, a subsequence of C is a sequence of elements Ci1, Ci2, …, Cik of C for which 0 ≤ i1 < i2 < ...< ik ≤ p.

입력

From the first line of the standard input, your program reads a positive integer n – the size of sequence A. From the second line, your program reads n positive integers – the elements of A. From the third line of the standard input, your program reads a positive integer m – the size of sequence B. From the fourth line, your program reads m positive integers – the elements of B.

출력

On the first line of the standard output, your program should print a positive integer p – the size of the chosen subsequence of A. On the second line, your program should print p integers – the indices of the chosen elements from A. On the third line of the standard output, your program should print a positive integer q – the size of the chosen subsequence of B. On the fourth line, your program should print q integers – the indices of the chosen elements from B.

Attention: Indices start from 0. The order in which your program prints the chosen indices doesn’t matter. It is guaranteed that at least one solution exists. If more than one solution exists, print any one of them.

제한

  • 1 ≤ n, m ≤ 1 000 000

서브태스크

번호배점제한
110

n, m ≤ 20

225

n, m ≤ 300

365

No additional constraints.

예제 입력 1

5
2 3 3 2 3
3
4 5 5

예제 출력 1

3
1 2 4
2
0 1

힌트

a[1] + a[2] + a[4] = 3 + 3 + 3 = 9

b[0] + b[1] = 4 + 5 = 9.

Another possible solution is: a[2] +a[3] = 3 + 2 = 5 = b[1].

출처

Olympiad > International Autumn Tournament in Informatics > 2021 > Group B (Juniors) 6번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /