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

26487번 - Palindrome 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB1633100.000%

문제

Little Square found an array $a$ consisting of $N$ positive numbers formed of nonzero digits. He can replace any number from $a$ with another number consisting of as many digits, all nonzero.

After making all the changes he wants, Little Square will form a new number $M$ by writing the elements of the array $a$ in order, without spaces. What is the minimum numbers of elements of the array $a$ which need to be replaced by Little Square for the number $M$ obtained to be a palindrome.

입력

The first line of standard input will contain an integer $N,ドル the size of the array $a$. The second line will contain $N$ integers consisting only of nonzero digits representing the array $a$.

Attention! The numbers read from the input file may be too big for the int data type. It is recommended to use the long long data type.

출력

The standard output will contain only one integer, representing the minimum number of elements of the array a that need to be replaced.

제한

  • 1ドル ≤ N ≤ 500,000円$
  • 1ドル ≤ a_i < 10^{18},ドル for every 1ドル ≤ i ≤ N$
  • A number is a palindrome if its first digit is equal to its last one, its second digit is equal is equal to the next to last digit and so on. Thus, numbers 4ドル,ドル 121ドル,ドル 14541ドル$ are palindromes, while numbers 21ドル,ドル 433ドル,ドル 1234312ドル$ are not palindromes.

서브태스크

번호배점제한
110

1ドル ≤ a_i ≤ 9,ドル for every 1ドル ≤ i ≤ N$

210

1ドル ≤ N ≤ 16$

315

1ドル ≤ N ≤ 32$

420

1ドル ≤ N ≤ 1000$

510

$M$ can become a palindrome by replacing at most 2ドル$ numbers.

635

No additional constraints.

예제 입력 1

6
13577 98 348 997 8 31

예제 출력 1

2

예제 입력 2

3
455 21 1347742112664

예제 출력 2

1

힌트

In the first example, Little Square can replace the first number with 13879ドル$ and the third number with 448ドル$. The number $M$ will become 1387998448997831ドル$ which is a palindrome. There is no solution with less than two replacements.

In the second example, Little Square can replace the third number with 1347743112554ドル$.

출처

Contest > infO(1) Cup > infO(1) Cup 2021 International Round 연습 세션 P2번

채점 및 기타 정보

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

출처

대학교 대회

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

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