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

S5. Circle of Life

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

You may have heard of Conway’s Game of Life,
which is a simple set of rules for cells on a grid that can produce
incredibly complex configurations. In this problem we will deal with a
simplified version of the game.

There is a one-dimensional circular strip of \(N\) cells. The cells are numbered from
\(1\) to \(N\) in the order you would expect: that is,
cell 1 and cell 2 are adjacent, cell 2 and cell 3 are adjacent, and so
on up to cell \(N-1\), which is
adjacent to cell \(N\). Since the strip
is circular, cell \(1\) is also
adjacent to cell \(N\).

Each cell is either alive (represented by a ‘1’) or dead (represented
by a ‘0’). The cells change over a number of generations. If
exactly one of a cell’s neighbours is alive in the
current generation, then the cell will be alive in the next generation.
Otherwise, the cell will be dead in the next generation.

Given the initial state of the strip, find the state after \(T\) generations.

제약

\((3 \leq N \leq 100\ 000; 1 \leq T \leq 10^{15})\)
\(N \leq 15\)
\(T \leq 15\)
\(N \leq 4000\)
\(T \leq 10\ 000\ 000\)

입력 형식

The first line will contain two space-separated integers \(N\) and \(T\) \((3 \leq N \leq 100\ 000; 1 \leq T \leq 10^{15})\). The second line will contain a string consisting of
exactly \(N\) characters, representing
the initial configuration of the \(N\)
cells. Each character in the string will be either ‘0’ or ‘1’. The
initial state of cell \(i\) is given by
the \(i\)-th character of the string.
The character ‘1’ represents an alive cell and the character ‘0’
represents a dead cell.

For 1 of the 15 available marks, \(N \leq 15\) and \(T \leq 15\).

For an additional 6 of the 15 available marks, \(N \leq 15\).

For an additional 4 of the 15 available marks, \(N \leq 4000\) and \(T \leq 10\ 000\ 000\).

Note that for full marks, solutions will need to handle 64-bit
integers. For example

  • in C/C++, the type long long should be
    used;

  • in Java, the type long should be
    used;

  • in Pascal, the type int64 should be
    used.

출력 형식

Output the string of \(N\)
characters representing the final state of the cells, in the same format
and order as the input.

예제 1
입력
7 1
0000001
출력
1000010
설명

Cell 1 and cell \(N-1\) are adjacent
to cell \(N\), and thus are alive after
one generation.

예제 2
입력
5 3
01011
출력
10100
설명

After one generation, the configuration becomes
00011.

After two generations, the configuration becomes
10111.

문제 정보

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

출처 CCC 2016 Senior

평가 및 의견

S5. Circle of Life

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

Log in to rate problems.

개별 의견

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

풀이 제출

S5. Circle of Life

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