Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- import java.math.*;
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- class Solution {
- public static void main(String args[]) {
- Scanner in = new Scanner(System.in);
- int L = in.nextInt();
- int H = in.nextInt();
- in.nextLine();
- String T = in.nextLine();
- String ROW="";
- String accepts = "ABCDEFGHIGKLMNOPQRSTUVWXYZ?";
- String[] splitted = new String[135];
- String input = "";
- int prevLen = 0;
- for (int i = 0; i < H; i++) {
- ROW = in.nextLine();
- int counter=0;
- for (int j = 0; j <= ROW.length() - 4; j+=4) {
- splitted[counter + prevLen] = ROW.substring(j, j + 4);
- counter++;
- }
- prevLen += ROW.length() / 4;
- }
- if (T.length()>0) {
- int[] charPos = new int[T.length()];
- System.out.println();
- for (int i = 1; i <= T.length(); i++) {
- char oneW = T.charAt(i - 1);
- int acceptPos = accepts.indexOf(oneW);
- if (acceptPos >= 0)
- charPos[i - 1] = acceptPos;
- else
- charPos[i - 1] = accepts.length()-1;
- }
- for (int outI = 0; outI < splitted.length; outI += ROW.length() / 4) {
- for (int i : charPos)
- System.out.print(splitted[i + outI]);
- System.out.println();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement