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

34775번 - Generating patterns 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1.5 초 2048 MB431100.000%

문제

Sandy is developing a new computer as part of the ambitious System for Binary Compression (SBC) project. This project is part of a major technological challenge known as the Interface for Compact Pattern Coding (ICPC), whose goal is to achieve maximum efficiency in writing large volumes of data.

The SBC proposal is bold: choose a base pattern $B,ドル consisting of 8ドル$ bits $b_0, \dots , b_7,ドル and from it generate any other pattern by applying only simple, fast operations.

Sandy wants to write a sequence of $N$ bits to memory, with $N ≥ 8,ドル denoted by $C = c_0, \dots , c_{N−1}$. Initially, memory contains only zeros. She may then repeat the following operation any number of times:

  • Choose an integer $i$ between $−7$ and $N − 1,ドル the position at which $B$ will be applied;
  • For each position of $B$ that overlaps the sequence, that is, for every $j$ from 0ドル$ to 7ドル$ such that 0ドル ≤ i + j ≤ N − 1,ドル replace $c_{i+j}$ with $b_j ⊕ c_{i+j},ドル where $⊕$ denotes the XOR (exclusive OR) operation.

The following example illustrates two applications of the procedure: applying pattern $B$ to content $C,ドル the final result $C′$ is obtained.

Since the data we want to write to memory is usually not random, Sandy believes that, with a good choice of base pattern $B,ドル it will be possible to produce the desired content with few operations.

To test this hypothesis, she needs your help: given the content $C$ that must be written to memory, determine the base pattern $B$ that minimizes the number of operations needed to generate $C$ as described, and also the number $Q$ of operations required.

It can be proven that it is always possible to write any content using this procedure. However, for the SBC project to be successful and earn the ICPC seal of excellence, your solution needs to be fast and efficient!

입력

The first line contains an integer $N$ (8ドル ≤ N ≤ 4096$), the length of $C$.

The second line contains a sequence of $N$ bits, representing $C,ドル the content that must be written to memory.

출력

Your program should print a single line containing the 8ドル$-bit sequence $B,ドル representing the base pattern that minimizes the number of operations, and an integer $Q,ドル representing the minimum number of operations.

If there is more than one pattern $B$ that minimizes the number of operations, print the one with the smallest integer value when interpreted in base 2ドル,ドル where $b_0$ is the most significant bit and $b_7$ is the least significant bit.

제한

예제 입력 1

9
101001111

예제 출력 1

00111101 2

예제 입력 2

12
111111001010

예제 출력 2

00010101 3

예제 입력 3

10
0101001111

예제 출력 3

01000011 2

노트

출처

ICPC > Regionals > Latin America > Sub-Regional Brasil do ACM ICPC > Maratona SBC de Programação 2025 G번

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

출처

대학교 대회

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

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