Connection Status:
Competition Arena > SquareCypher
TCO07 Round 1C · 2007-03-07 · by Mike Mirzayanov · Simulation
Class Name: SquareCypher
Return Type: String
Method Name: decrypt
Arg Types: (string)
Problem Statement

Problem Statement

Square cypher is very simple and easy to decrypt. It encrypts a message s=s0s1...sn-1 in the following way: all characters situated on square positions (0, 1, 4, 9, 16...) are moved to the front of the message. The relative order of the moved characters remains the same. For example, the message "thisisacontest" will be encrypted as "thinissacotest".

You are given a String cryptogram. Decrypt it and return the result.

Constraints

  • cryptogram will contain between 1 and 50 characters, inclusive.
  • cryptogram will contain only lowercase letters ('a'..'z').
Examples
0)
"thinissacotest"
Returns: "thisisacontest"

This test is from the statement.

1)
"thisisacontest"
Returns: "thisiaconstest"
2)
"heoll"
Returns: "hello"

Only the letter 'o' was moved.

3)
"test"
Returns: "test"

Obviously, short messages (not longer than 4 characters) are not change after the encryption.

4)
"b"
Returns: "b"

Submissions are judged against all 66 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class SquareCypher with a public method string decrypt(string cryptogram) · 66 test cases · 2 s / 256 MB per case

Submitting as anonymous