結果

問題 No.1831 Parasol
ユーザー ks2mks2m
提出日時 2022-02-04 22:56:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 76,512 KB
実行使用メモリ 61,512 KB
最終ジャッジ日時 2023-09-02 05:39:03
合計ジャッジ時間 7,696 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,888 KB
testcase_01 AC 279 ms
60,828 KB
testcase_02 AC 124 ms
55,568 KB
testcase_03 AC 128 ms
56,004 KB
testcase_04 AC 270 ms
61,224 KB
testcase_05 AC 127 ms
56,076 KB
testcase_06 AC 127 ms
55,596 KB
testcase_07 AC 276 ms
60,964 KB
testcase_08 AC 128 ms
55,824 KB
testcase_09 AC 130 ms
55,600 KB
testcase_10 AC 270 ms
60,596 KB
testcase_11 AC 276 ms
61,512 KB
testcase_12 AC 233 ms
58,664 KB
testcase_13 AC 277 ms
60,616 KB
testcase_14 AC 184 ms
56,384 KB
testcase_15 AC 208 ms
56,504 KB
testcase_16 AC 132 ms
56,028 KB
testcase_17 AC 131 ms
55,868 KB
testcase_18 AC 183 ms
56,320 KB
testcase_19 AC 124 ms
55,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int end = n * 2 - 1;
		List<List<Integer>> list = new ArrayList<>(end);
		for (int i = 0; i < end; i++) {
			list.add(new ArrayList<>(n));
		}

		for (int i = end; i > n; i--) {
			for (int j = 0; j < i; j++) {
				list.get(j).add(i);
			}
		}
		for (int i = 1; i <= n; i++) {
			list.get(i - 1).add(i);
		}
		for (int i = n; i > 0; i--) {
			for (int j = end - i + 1; j < end; j++) {
				list.get(j).add(i);
			}
		}

		System.out.println(end);
		for (int i = 0; i < end; i++) {
			StringBuilder sb = new StringBuilder();
			for (int e : list.get(i)) {
				sb.append(e).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}
}
0