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

32830번 - Cards Flipping 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB40619216149.085%

문제

The magician $B$ has $n$ cards in a row on a desk. Each card has two sides with colors. The top side of a card is the side facing upwards. The bottom side of a card is the side facing downwards. Each side of a card has one color. We want to find the maximum number of distinct colors on the top sides. In the following example, we are given 5ドル$ cards in a row on a desk. The colors of the top sides of the cards are violet, red, violet, violet, and red from the left to the right as shown in the following figure. The colors of the bottom sides of the cards are red, violet, blue, yellow, and red from the left to the right.

If we flip a card, then the top side and the bottom side of the card are exchanged. If we flip the 3ドル$rd and the 4ドル$th card from the left, then the colors of the cards on the top sides become like the following.

The number of distinct colors on the top sides becomes 4ドル$ which is the maximum for the example.

Given $n$ cards placed in a row on a desk and the colors on the sides of cards, write a program to output the maximum number of distinct colors on the top sides.

입력

Your program is to read from the standard input. The input starts with a line containing an integer $n$ (1ドル ≤ n ≤200,000円$), where $n$ is the number of cards. The cards are numbered from 1ドル$ to $n$. In the following two lines, the first line contains the colors on the top sides of cards from the card 1ドル$ to the card $n$. The second line contains the colors on the bottom sides of cards from the card 1ドル$ to the card $n$. Each color is represented by a nonnegative integer, not exceeding 10ドル^6$.

출력

Your program is to write to the standard output. Print exactly one line. The line should contain the maximumnumber of distinct colors on the top sides.

제한

예제 입력 1

5
0 1 0 0 1
1 0 2 3 1

예제 출력 1

4

예제 입력 2

2
3 5
5 1

예제 출력 2

2

예제 입력 3

3
0 1 0
1 0 2

예제 출력 3

3

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > 2024 ICPC Asia Seoul Regional B번

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

출처

대학교 대회

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

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