結果

問題 No.2256 Step by Step
ユーザー CuriousFairy315CuriousFairy315
提出日時 2023-03-25 00:51:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,208 bytes
コンパイル時間 3,212 ms
コンパイル使用メモリ 77,500 KB
実行使用メモリ 58,252 KB
最終ジャッジ日時 2023-10-18 21:52:01
合計ジャッジ時間 11,901 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
57,704 KB
testcase_01 AC 131 ms
57,284 KB
testcase_02 AC 166 ms
57,840 KB
testcase_03 AC 160 ms
57,312 KB
testcase_04 WA -
testcase_05 AC 165 ms
57,300 KB
testcase_06 AC 133 ms
57,656 KB
testcase_07 AC 129 ms
57,656 KB
testcase_08 AC 119 ms
56,260 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 129 ms
57,280 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 141 ms
57,644 KB
testcase_16 AC 151 ms
57,284 KB
testcase_17 AC 128 ms
56,168 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 145 ms
57,652 KB
testcase_24 AC 138 ms
57,668 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 144 ms
57,308 KB
testcase_28 WA -
testcase_29 AC 141 ms
57,540 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import static java.lang.System.err;

public class Main {
	public static void main(String[] args) {
		java.io.PrintWriter out = new java.io.PrintWriter(System.out);
		new Main(out);
		out.flush();
		err.flush();
	}

	/*
	 * 考察
	 * 連結パーツを作りたい
	 *
	 * 124
	 * 03x
	 * 03x
	 * 011
	 * 232
	 * 44x
	 * を始点パーツ
	 * x13
	 * 02x
	 * 12x
	 * x00
	 * x21
	 * 33x
	 * を接続パーツ
	 * x24
	 * 013
	 * 213
	 * x00
	 * x12
	 * 443
	 * を終点パーツとすると、5+2xは作れる
	 * 3665
	 * 244x
	 * 211x
	 * 1000
	 * 2334
	 * 455x
	 * で6+2xも作れる
	 * あ、勝ちました
	 * 1だと100011で良い、2は不可能が示せるので終了
	 * あ、終点パーツすら要らなくて笑うわ
	 * 始点二つと接続だけで解けた
	 */
	public Main(java.io.PrintWriter out) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int N = sc.nextInt();
			int[][][] first = {
					{ { 3, 6, 6, 5 }, { 0, 4, 4, -1 }, { 0, 1, 1, -1 }, { 1, 2, 2, 2 }, { 0, 3, 3, 4 },
							{ 6, 5, 5, -1 } },
					{ { 1, 2, 4 }, { 0, 3, -1 }, { 0, 3, -1 }, { 0, 1, 1 }, { 2, 3, 2 }, { 4, 4, -1 } } };
			int[][] joint = { { -1, 1, 3 }, { 0, 2, -1 }, { 1, 2, -1 }, { -1, 0, 0 }, { -1, 2, 1 }, { 3, 3, -1 } };
//			int[][] last = { { -1, 2, 4 }, { 0, 1, 3 }, { 2, 1, 3 }, { -1, 0, 0 }, { -1, 1, 2 }, { 4, 4, 3 } };
			if (N == 1) {
				out.println("0\n1\n1\n1\n0\n0");
			} else if (N == 2) {
				out.println(-1);
			} else {
				int x = 0, add = 0;
				int[][] ans = new int[6][N];
				add = joint(ans, first[N % 2], 0, add);
				x += (N + 1) % 2 + 2;
				while(x < N - 3) {
					add = joint(ans, joint, x, add);
					x += 2;
				}
				if (x == N - 3) joint(ans, joint, x, add);
				print(ans, out);
			}
		}
	}

	public int joint(int[][] ans, int[][] block, int first, int add) {
		int plus = 0;
		for (int y = 0;y < 6;++ y) {
			for (int x = 0;x < block[y].length;++ x) {
				if (block[y][x] == -1) continue;
				ans[y][first + x] = (block[y][x] + add) % 10;
				++plus;
			}
		}
		return (add + plus / 3) % 10;
	}

	public void print(int[][] ans, java.io.PrintWriter out) {
		for (int[] i : ans) {
			for (int j : i) out.print(j);
			out.println();
		}
	}
}
0