11223 - O: dah dah dah!

All about problems in Volume 112. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
juan321
New poster
Posts: 2
Joined: Sat Jan 23, 2016 1:43 am

11223 - O: dah dah dah!

Post by juan321 »

Why im still getting WA?

Code: Select all

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
class Main {

	public static void main(String[] args) throws Throwable {

		Map<String, Character> maped = new HashMap<String, Character>();
		maped.put(".-", 'A');
		maped.put("-...", 'B');
		maped.put("-.-.", 'C');
		maped.put("-..", 'D');
		maped.put(".", 'E');
		maped.put("..-.", 'F');
		maped.put("--.", 'G');
		maped.put("....", 'H');
		maped.put("..", 'I');
		maped.put(".---", 'J');
		maped.put("-.-", 'K');
		maped.put(".-..", 'L');
		maped.put("--", 'M');
		maped.put("-.", 'N');
		maped.put("---", 'O');
		maped.put(".--.", 'P');
		maped.put("--.-", 'Q');
		maped.put(".-.", 'R');
		maped.put("...", 'S');
		maped.put("-", 'T');
		maped.put("..-", 'U');
		maped.put("...-", 'V');
		maped.put(".--", 'W');
		maped.put("-..-", 'X');
		maped.put("-.--", 'Y');
		maped.put("--..", 'Z');
		maped.put("-----", '0');
		maped.put(".----", '1');
		maped.put("..---", '2');
		maped.put("...--", '3');
		maped.put("....-", '4');
		maped.put(".....", '5');
		maped.put("-....", '6');
		maped.put("--...", '7');
		maped.put("---..", '8');
		maped.put("----.", '9');
		maped.put(".-.-.-", '.');
		maped.put("--..--", ',');
		maped.put("..--..", '?');
		maped.put(".----.", '\'');
		maped.put("-.-.--", '!');
		maped.put("-..-. ", '/');
		maped.put("-.–.", '(');
		maped.put("-.--.-", ')');
		maped.put(".-...", '&');
		maped.put("---...", ':');
		maped.put("-.-.-.", ';');
		maped.put("-...-", '=');
		maped.put(".-.-.", '+');
		maped.put("-....-", '-');
		maped.put("..--.-", '_');
		maped.put(".-..-.", '"');
		maped.put(".--.-.", '@');

		BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
		String linea = lector.readLine();
		int c = 1;
		int casos = Integer.parseInt(linea);
		while (c <= casos && linea != null) {
			linea = lector.readLine();
			String msj[] = linea.split(" ");
			String out = "";
			for (int i = 0; i < msj.length; i++) {
				if (maped.get(msj[i])==null) {
					out += " ";
				} else {
					out += maped.get(msj[i]);
				}
			}
			System.out.println("Message #" + c);
			System.out.println(out);
			c++;
		}
	}
}
Post Reply

Return to “Volume 112 (11200-11299)”