diff --git a/anakamura/src/C114.java b/anakamura/src/C114.java new file mode 100644 index 0000000000000000000000000000000000000000..0f0b6cba60794da678d431d9ceff94cbb1d71078 --- /dev/null +++ b/anakamura/src/C114.java @@ -0,0 +1,42 @@ +package anakamura.src; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class C114 { + public static void main(String[] args) { + final var sc = new Scanner(System.in); + + // 一番初めの文字取得 + final int N = sc.nextInt(); + sc.nextLine(); + // Listを作成し、すべての文字列を取得 + final List words = new ArrayList<>(); + for (int i = 0; i < N; i++) { + words.add(sc.nextLine()); + } + sc.close(); + System.out.println(wordsCheckMethod(words)); + + } + + public static String wordsCheckMethod(final List words) { + for (int i = 0; i < words.size() - 1; i++) { + final String currentword = words.get(i); + // 初めの単語の末尾を取得 + final char char1 = (currentword.charAt(currentword.length() - 1)); + // 次の単語の先頭の文字を取得 + final char char2 = (words.get(i + 1).charAt(0)); + // char1とchar2が等しくない場合、こちらを出力 + if (char1 != char2) { + final StringBuilder sb = new StringBuilder(); + sb.append(char1).append(" ").append(char2); + return sb.toString(); + } + } + // すべて等しいときは、こちらを出力 + return "Yes"; + } + +} diff --git a/anakamura_2/Main.java b/anakamura_2/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..7c57b42553ed6beee140938afd4f3c25b96dcf44 --- /dev/null +++ b/anakamura_2/Main.java @@ -0,0 +1,69 @@ +package anakamura_2; + +import java.util.Scanner; + +public class Main { + /* + * private int numberOfMoves; //移動回数 private int rowsOfMatrix; // 縦の列の数 private int colsOfMatrix; + * //横の列の数 private int rows; //自分の行 private int cols; //自分の列 array[] char array; + */ + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + + final int numberOfMoves = sc.nextInt(); // 移動回数 + final int rowsOfMatrix = sc.nextInt(); // 縦の列の数 + final int colsOfMatrix = sc.nextInt(); // 横の列の数 + + final int rows = sc.nextInt(); // 自分の行 + final int cols = sc.nextInt();// 自分の列 + + final String movedRoute = sc.next();// 移動経路 + + char[] array = new char[movedRoute.length()]; + for (int i = 0; i < movedRoute.length(); i++) { + char movement = (movedRoute.charAt(i)); + array[i] = movement; + } + Sub sub = new Sub(); + // movedRoute.length()==numberOfMoves;//文字列の長さは移動回数の長さと同じ! + + /* + * i 行目の j 番目 (1 ≦ j ≦ W) の整数 c_{i, j} は前から i 列目、 から j 列目に座っているクラスメイトがくれるチョコレートの数を表す。 + */ + final int[][] matrix = new int[rowsOfMatrix][colsOfMatrix]; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < rows; j++) { + matrix[i][j] = sc.nextInt(); + } + } + sc.close(); + + int choco[] = new int[movedRoute.length()]; + + for (int i = 0; i < array.length; i++) { + switch (array[i]) { + case 'F': + sub.moveF(rows, cols); + + break; + case 'B': + sub.moveB(rows, cols); + break; + case 'L': + sub.moveL(rows, cols); + break; + case 'R': + sub.moveR(rows, cols); + break; + } + choco[i] = matrix[sub.getrows()][sub.getcols()]; + } + for (int num : choco) { + System.out.println(num); + } + // 移動方向 + // public void + } +} diff --git a/anakamura_2/Sub.java b/anakamura_2/Sub.java new file mode 100644 index 0000000000000000000000000000000000000000..008a427e1bd097c7517d04c65a85eec28be7aa76 --- /dev/null +++ b/anakamura_2/Sub.java @@ -0,0 +1,28 @@ +package anakamura_2; + +public class Sub{ + private int rows,cols; + // Sub(int rows, int cols) {} + public int getrows() { + return rows; + } + public int getcols() { + return cols;} + + + public void moveF(int rows,int cols) { + rows +=1; + } + public void moveB(int rows,int cols) { + rows -=1; + } + public void moveL(int rows,int cols) { + cols +=1; + } + public void moveR(int rows,int cols) { + cols -=1; + } + // TODO 自動生成されたメソッド・スタブ + + + }