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

27475번 - Cancel the Trains 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 512 MB31328526191.579%

문제

Gildong’s town has a train system that has 100ドル$ trains that travel from the bottom end to the top end and 100ドル$ trains that travel from the left end to the right end. The trains starting from each side are numbered from 1ドル$ to 100ドル,ドル respectively, and all trains have the same speed. Let’s take a look at the picture below.

The train system can be represented as coordinates on a 2D plane. The $i$-th train starting at the bottom end is initially at $(i,0)$ and will be at $(i,T)$ after $T$ minutes, and the $i$-th train starting at the left end is initially at $(0,i)$ and will be at $(T,i)$ after $T$ minutes. All trains arrive at their destinations after 101ドル$ minutes.

However, Gildong found that some trains scheduled to depart at a specific time, simultaneously, are very dangerous. At this time, $n$ trains are scheduled to depart from the bottom end and $m$ trains are scheduled to depart from the left end. If two trains are both at $(x,y)$ at the same time for some $x$ and $y,ドル they will crash into each other. Therefore, he is asking you to find the minimum number of trains that should be cancelled to prevent all such crashes.

입력

Each test contains one or more test cases. The first line contains the number of test cases $t$ (1ドル\le t\le 100$).

Each test case contains three lines. The first line of each test case consists of two integers $n$ and $m$ (1ドル\le n,m\le 100$) --- the number of trains scheduled to depart from the bottom end, and the number of trains scheduled to depart from the left end, respectively.

The second line of each test case contains $n$ integers. Each integer is a train number that is scheduled to start from the bottom end. The numbers are given in strictly increasing order, and are between 1ドル$ and 100ドル,ドル inclusive.

The third line of each test case contains $m$ integers. Each integer is a train number that is scheduled to start from the left end. The numbers are given in strictly increasing order, and are between 1ドル$ and 100ドル,ドル inclusive.

출력

For each test case, print a single integer: the minimum number of trains that should be canceled in order to prevent all crashes.

제한

예제 입력 1

3
1 2
1
3 4
3 2
1 3 4
2 4
9 14
2 7 16 28 33 57 59 86 99
3 9 14 19 25 26 28 35 41 59 85 87 99 100

예제 출력 1

0
1
3

노트

In the first case, we can show that there will be no crashes if the current schedule is followed. Therefore, the answer is zero.

In the second case, at $T=4,ドル there will be a crash, as can be seen in the picture below. We can prove that after canceling one of these trains, the remaining trains will not crash. Therefore, the answer is one.

출처

Contest > Codeforces > Codeforces Round 688 (Div. 2) A번

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

출처

대학교 대회

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

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