結果

問題 No.893 お客様を誘導せよ
ユーザー tentententen
提出日時 2020-08-30 21:42:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 589 ms / 2,000 ms
コード長 849 bytes
コンパイル時間 3,118 ms
コンパイル使用メモリ 72,292 KB
実行使用メモリ 62,720 KB
最終ジャッジ日時 2023-08-09 18:39:23
合計ジャッジ時間 8,446 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,528 KB
testcase_01 AC 123 ms
55,520 KB
testcase_02 AC 292 ms
60,188 KB
testcase_03 AC 476 ms
60,796 KB
testcase_04 AC 458 ms
60,856 KB
testcase_05 AC 444 ms
60,328 KB
testcase_06 AC 375 ms
60,704 KB
testcase_07 AC 124 ms
55,656 KB
testcase_08 AC 589 ms
62,720 KB
testcase_09 AC 197 ms
58,348 KB
testcase_10 AC 133 ms
55,628 KB
testcase_11 AC 180 ms
56,208 KB
testcase_12 AC 201 ms
58,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	ArrayDeque<ArrayDeque<Integer>> all = new ArrayDeque<>();
    	for (int i = 0; i < n; i++) {
    	    int p = sc.nextInt();
    	    if (p == 0) {
    	        continue;
    	    }
    	    ArrayDeque<Integer> tmp = new ArrayDeque<>();
    	    for (int j = 0; j < p; j++) {
    	        tmp.add(sc.nextInt());
    	    }
    	    all.add(tmp);
    	}
    	StringBuilder sb = new StringBuilder();
    	while (all.size() > 0) {
    	    ArrayDeque<Integer> tmp = all.poll();
    	    if (sb.length() > 0) {
    	        sb.append(" ");
    	    }
    	    sb.append(tmp.poll());
    	    if (tmp.size() > 0) {
    	        all.add(tmp);
    	    }
    	}
    	System.out.println(sb);
    }
}
0