oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

customencryption Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

customencryption.html

Problem Description

Mice are lazy. But if you think about it, lazy people get more things done than those who laborously do things. Such as trying to encrypt a string. Others will take a pen and paper and slowly work though the steps to encrypt it. But Squeaky Mouse will create a program to do the job for him.

So, as it seems, Squeaky has found a huge stash of cheese, and he wants to tell his best friend Squealy about it. As this is a top-secret mission, Squeaky uses a custom method to encrypt his message. Since other advanced encryption methods are hard to understand and usually comes with a bunch if Wikipedia-ish gibberish, he will derive his encryption method from the simple ROT-13 method.

ROT13 ("rotate by 13 places", sometimes hyphenated ROT-13) is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher, developed in ancient Rome.
~ Wikipedia

So A gets replaced by N and N gets replaced by A, and so on.

Squeaky will supply the message in chunks, and occasionally, you will be asked to encrypt the message so far using ROT-13 encryption.

As the resulting encrypted message may be very long, you will convert each character to a number (A = 1, B = 2, ..., Z = 26) and output the sum of all the numbers.

Input

There is only one line. It will be in this format:

<char1>[length1][!]<char2>[length2][!]...<charn>[lengthn][!]

"<>" denotes a required field, "[]" denotes an optional field.

char is a single lowercase character from a to z.

length is a integer which is the number of copies of char to add to the back of the message string. If it is not specified, it means only one copy of char is added to the message string. length will be at most 1000000.

An exclamation mark (!) denotes that ROT-13 encryption should be applied onto the whole message so far.

Examples are below.

Output

The output should contain exactly one integer, the sum of all the numbers after converting each character to a number.

Limits

Let L be the length of the input string.

0 < L ≤ 106 for all subtasks.

Subtask 1 (10%): length will never be specified; there will be no exclamation marks.

Subtask 2 (30%): length will never be specified.

Subtask 3 (20%): there will be no exclamation marks.

Subtask 4 (40%): no further restructions.

Subtask 5 (0%): Sample

Sample Input 1

ab3!c!d4t!

Sample Output 1

137

Sample Input 2 (satisfies subtask 2)

ter!hello!p

Sample Output 2

150

Tags

String Processing

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
110101s32MBMinimum
230101s32MBMinimum
320101s32MBMinimum
440301s32MBMinimum
5021s32MBMinimum

Judge Compile Command

g++-8 ans.cpp -o customencryption -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.