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

15466번 - Similarity Computation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB13311310184.167%

문제

The Jaccard similarity coefficient is usually used for measuring the similarity of two sets. Give two sets A and B, the Jaccard similarity coefficient, J(A, B), is defined as the size of the intersection divided by the size of the union of the two sets. That is, J(A, B) = |A∩B|/|A∪B|. For example, if A = {1, 3, 7, 8} and B = {1, 7, 9}, then J(A, B) = |{1,7}|/|{1,3,7,8,9}| = 2/5.

Assume the element i in the set is an integer between 0 to 9 (0 ≤ i ≤ 9) and the size of the set is no larger than 10. Please write a program to compute the Jaccard similarity coefficient of two sets A and B. And output 1 if J(A, B) > 0.5 and 0 if J(A, B) ≤ 0.5.

입력

The first line of the input file contains an integer T (T ≤ 25) indicating the number of test cases to follow.

Each test case will consist of three lines. The first line contains two integers m and n (0 < m, n ≤ 10), indicating the number of elements of sets A and B, respectively. The second line contains m integers (the elements of set A) and the third line contains n integers (the elements of set B).

You may assume:

  • 1 ≤ T ≤ 25
  • m ≤ 10 and n ≤ 10

출력

For each test case, output 1 if J(A, B) > 0.5 and 0 if J(A, B) ≤ 0.5.

제한

예제 입력 1

3
5 6
0 2 3 5 6
1 2 4 6 7 9
3 2
1 4 6
4 6
7 7
0 1 3 4 6 8 9
0 1 2 3 4 6 7

예제 출력 1

0
1
1

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2017 A번

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

출처

대학교 대회

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

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