RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 ICPC00134

F. Beppa and SwerChat

설명

Beppa and her circle of geek friends keep up to date on a group chat in the instant messaging app Swer\(Chat^{TM}\). The group has \(n\) members, excluding Beppa. Each of those members has a unique ID between 1 and \(n\). When a user opens a group chat, Swer\(Chat^{TM}\) displays the list of other members of that group, sorted by decreasing times of last seen online (so the member who opened the chat most recently is the first of the list). However, the times of last seen are not displayed. Today, Beppa has been busy all day: she has only opened the group chat twice, once at 9:00 and once at 22:00. Both times, she wrote down the list of members in the order they appeared at that time. Now she wonders: what is the minimum number of other members that must have been online at least once between 9:00 and 22:00? Beppa is sure that no two members are ever online at the same time and no members are online when Beppa opens the group chat at 9:00 and 22:00.

제약
입력 형식

Each test contains multiple test cases. The first line contains an integer \(t\) (\(1 \le t \le 10\,000\)) — the number of test cases. The descriptions of the \(t\) test cases follow. The first line of each test case contains an integer \(n\) (\(1 \le n \le 10^{5}\)) — the number of members of the group excluding Beppa. The second line contains \(n\) integers \(a_{1}\), \(a_{2}\), . . . , \(a_{n}\) (\(1 \le a_{i} \le n\)) — the list of IDs of the members, sorted by decreasing times of last seen online at 9:00. The third line contains \(n\) integers \(b_{1}\), \(b_{2}\), . . . , \(b_{n}\) (\(1 \le b_{i} \le n\)) — the list of IDs of the members, sorted by decreasing times of last seen online at 22:00. For all \(1 \le i < j \le n\), it is guaranteed that \(a_{i}\)̸ = \(a_{j}\) and \(b_{i}\)̸ = \(b_{j}\). It is also guaranteed that the sum of the values of \(n\) over all test cases does not exceed \(10^{5}\).

출력 형식

For each test case, print the minimum number of members that must have been online between 9:00 and 22:00. Problem F: Beppa and SwerChat SWERC \(2022-2023\)

예제 1
입력
4
5
1 4 2 5 3
4 5 1 2 3
6
1 2 3 4 5 6
1 2 3 4 5 6
8
8 2 4 7 1 6 5 3
5 6 1 4 8 2 7 3
1
1
1
출력
2
0
4
0
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC SWERC 2022

평가 및 의견

F. Beppa and SwerChat

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

F. Beppa and SwerChat

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8