結果

問題 No.326 あみだますたー
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-03 16:52:56
言語 Java21
(openjdk 21)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,883 bytes
コンパイル時間 4,332 ms
コンパイル使用メモリ 82,604 KB
実行使用メモリ 64,056 KB
最終ジャッジ日時 2024-04-25 13:11:28
合計ジャッジ時間 13,087 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 148 ms
54,288 KB
testcase_01 AC 180 ms
54,932 KB
testcase_02 AC 224 ms
55,448 KB
testcase_03 AC 405 ms
60,220 KB
testcase_04 AC 255 ms
55,548 KB
testcase_05 AC 136 ms
54,296 KB
testcase_06 AC 323 ms
59,928 KB
testcase_07 AC 216 ms
56,888 KB
testcase_08 AC 301 ms
55,388 KB
testcase_09 AC 449 ms
59,960 KB
testcase_10 MLE -
testcase_11 AC 170 ms
54,848 KB
testcase_12 AC 352 ms
59,952 KB
testcase_13 AC 374 ms
59,824 KB
testcase_14 AC 277 ms
58,332 KB
testcase_15 AC 299 ms
59,736 KB
testcase_16 AC 286 ms
59,552 KB
testcase_17 AC 318 ms
58,156 KB
testcase_18 AC 299 ms
59,032 KB
testcase_19 AC 316 ms
59,984 KB
testcase_20 AC 141 ms
54,704 KB
testcase_21 AC 160 ms
54,916 KB
testcase_22 AC 352 ms
60,068 KB
testcase_23 AC 362 ms
59,932 KB
testcase_24 AC 385 ms
60,100 KB
testcase_25 AC 382 ms
59,820 KB
testcase_26 AC 240 ms
58,372 KB
testcase_27 AC 354 ms
60,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise53{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    int vert = sc.nextInt();
    int hori = sc.nextInt();

    int[][] lines = new int[hori][2];

    for (int a = 0; a < hori; a++){
      lines[a][0] = sc.nextInt();
      lines[a][1] = sc.nextInt();
    }

    int[] answer = new int[vert];

    for (int b = 0; b < vert; b++){
      answer[b] = sc.nextInt();
    }

    LinkedList<int[]> newLines1 = new LinkedList<int[]>();
    LinkedList<int[]> newLines2 = new LinkedList<int[]>();

    int[] process = new int[vert];

    for (int i = 0; i < vert; i++){
      int currentNum = i + 1;
      for (int j = 0; j < hori; j++){
        if (currentNum == lines[j][0]){
          currentNum++;
        }else if(currentNum == lines[j][1]){
          currentNum--;
        }
      }
      process[i] = currentNum;
    }
    getNewHori(vert, process, newLines1, true);

    getNewHori(vert, answer, newLines2, false);



    System.out.println(newLines1.size() + newLines2.size());
    showLines(newLines1);
    showLines(newLines2);

  }

  private static void getNewHori(int vert, int[] array, LinkedList<int[]> arrayList, boolean flag){
    for (int k = 0; k < vert - 1; k++){
      for (int i = vert - 1; i > k; i--){
        if (array[i] < array[i - 1]){
          int w = array[i];
          array[i] = array[i - 1];
          array[i - 1] = w;
          int[] newLine = new int[2];
          newLine[0] = i;
          newLine[1] = i + 1;
          if (flag){
            arrayList.push(newLine);
          }else{
            arrayList.add(newLine);
          }
        }
      }
    }
  }

  private static void showLines(LinkedList<int[]> arrayList){
    for (int i = 0; i < arrayList.size(); i++){
      int[] line = arrayList.get(i);
      System.out.println(line[0] + " " + line[1]);
    }
  }
}
0