Advertisement
Guest User

Untitled

a guest
Aug 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4.  
  5. /**
  6. * Auto-generated code below aims at helping you parse
  7. * the standard input according to the problem statement.
  8. **/
  9. class Solution {
  10. public static void main(String args[]) {
  11. Scanner in = new Scanner(System.in);
  12. int L = in.nextInt();
  13. int H = in.nextInt();
  14. in.nextLine();
  15. String T = in.nextLine();
  16. String ROW="";
  17. String accepts = "ABCDEFGHIGKLMNOPQRSTUVWXYZ?";
  18. String[] splitted = new String[135];
  19. String input = "";
  20. int prevLen = 0;
  21. for (int i = 0; i < H; i++) {
  22. ROW = in.nextLine();
  23. int counter=0;
  24. for (int j = 0; j <= ROW.length() - 4; j+=4) {
  25. splitted[counter + prevLen] = ROW.substring(j, j + 4);
  26. counter++;
  27. }
  28. prevLen += ROW.length() / 4;
  29. }
  30. if (T.length()>0) {
  31. int[] charPos = new int[T.length()];
  32. System.out.println();
  33. for (int i = 1; i <= T.length(); i++) {
  34. char oneW = T.charAt(i - 1);
  35. int acceptPos = accepts.indexOf(oneW);
  36. if (acceptPos >= 0)
  37. charPos[i - 1] = acceptPos;
  38. else
  39. charPos[i - 1] = accepts.length()-1;
  40. }
  41.  
  42. for (int outI = 0; outI < splitted.length; outI += ROW.length() / 4) {
  43. for (int i : charPos)
  44. System.out.print(splitted[i + outI]);
  45. System.out.println();
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement