Submission details
Task:Decrypt
Sender:PILIPOJAT!!
Submission time:2016-09-06 17:58:02 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/Main.java:1: warning: SourceTree is internal proprietary API and may be removed in a future release
import com.sun.org.apache.xpath.internal.SourceTree;
                                        ^
input/Main.java:27: error: cannot find symbol
            System.out.println(new String(encryptedMessage));
                                          ^
  symbol:   variable encryptedMessage
  location: class Main
1 error
1 warning

Code

import com.sun.org.apache.xpath.internal.SourceTree;

import java.util.*;
import java.io.*;

/**
 * Created by migho on 6.9.2016.
 */
public class Main {

    //nopqrstuvwxyzabcdefghijklmn
    //tbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrntbbqvqrn

    public static void main(String[] argv) {
        IO io = new IO();

        // characters
        char[] f = io.next().toCharArray();

        //rounds
        int k = io.nextInt();

        //encrypted message
        char[] encryptedString = io.next().toCharArray();

        if(k % 2 == 0) {
            System.out.println(new String(encryptedMessage));
            System.exit(0);
        }

        char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();

        for (int offset = 0; offset < encryptedString.length; offset++) {
            char c = encryptedString[offset];
            int pos = 0;
            for (char x : f) {
                if (x == c) {
                    break;
                }
                pos++;
            }
            //int pos = Arrays.binarySearch(f, c);
            if (pos > 25) {
                System.out.println("impossible");
                System.exit(0);
            }
            encryptedString[offset] = alphabet[pos];
        }
        System.out.println(new String(encryptedString));
    }

}