포럼
문제 ICPC00196

K. Kleptography

설명

John likes simple ciphers. He had been using the "Caesar" cipher to encrypt his diary until recently, when he learned a hard lesson about its strength by catching his sister Mary browsing through the diary without any problems.

Rapidly searching for an alternative, John found a solution: the famous "Autokey" cipher. He uses a version that takes the \(26\) lower-case letters 'a'–'z' and internally translates them in alphabetical order to the numbers \(0\) to \(25\).

The encryption key \(k\) begins with a secret prefix of \(n\) letters. Each of the remaining letters of the key is copied from the letters of the plaintext \(a\), so that \(k_{n+i} = a_{i}\) for \(i \geq 1\). Encryption of the plaintext \(a\) to the ciphertext \(b\) follows the formula \(b_i = a_i + k_i \bmod 26\).

Mary is not easily discouraged. She was able to get a peek at the last \(n\) letters John typed into his diary on the family computer before he noticed her, quickly encrypted the text document with a click, and left. This could be her chance.

제약
입력 형식

The input consists of:
- One line with two integers \(n\) and \(m\) (\(1 \le n \le 30\), \(n + 1 \le m \le 100\)), where \(n\) is the length of the keyword as well as the number of letters Mary saw, and \(m\) is the length of the text.
- One line with \(n\) lower-case letters, the last \(n\) letters of the plaintext.
- One line with \(m\) lower-case letters, the whole ciphertext.

출력 형식

Output the plaintext of John's diary.

예제 1
입력
5 16
again
pirpumsemoystoal
출력
marywasnosyagain
예제 2
입력
1 12
d
fzvfkdocukfu
출력
shortkeyword
문제 정보

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

출처 ICPC NWERC 2018

평가 및 의견

K. Kleptography

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

Log in to rate problems.

개별 의견

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

풀이 제출

K. Kleptography

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