結果
問題 | No.2256 Step by Step |
ユーザー | CuriousFairy315 |
提出日時 | 2023-03-25 04:17:15 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 1,796 bytes |
コンパイル時間 | 3,343 ms |
コンパイル使用メモリ | 78,112 KB |
実行使用メモリ | 57,700 KB |
最終ジャッジ日時 | 2023-10-18 21:54:31 |
合計ジャッジ時間 | 9,866 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 141 ms
57,672 KB |
testcase_01 | AC | 141 ms
57,648 KB |
testcase_02 | AC | 176 ms
57,588 KB |
testcase_03 | AC | 174 ms
57,612 KB |
testcase_04 | AC | 174 ms
57,588 KB |
testcase_05 | AC | 177 ms
55,612 KB |
testcase_06 | AC | 140 ms
57,184 KB |
testcase_07 | AC | 140 ms
57,648 KB |
testcase_08 | AC | 136 ms
57,700 KB |
testcase_09 | AC | 137 ms
57,588 KB |
testcase_10 | AC | 137 ms
57,656 KB |
testcase_11 | AC | 140 ms
57,624 KB |
testcase_12 | AC | 144 ms
57,584 KB |
testcase_13 | AC | 148 ms
57,620 KB |
testcase_14 | AC | 146 ms
57,328 KB |
testcase_15 | AC | 145 ms
57,688 KB |
testcase_16 | AC | 144 ms
57,660 KB |
testcase_17 | AC | 146 ms
57,480 KB |
testcase_18 | AC | 170 ms
57,580 KB |
testcase_19 | AC | 149 ms
57,620 KB |
testcase_20 | AC | 147 ms
57,644 KB |
testcase_21 | AC | 147 ms
57,580 KB |
testcase_22 | AC | 151 ms
57,400 KB |
testcase_23 | AC | 147 ms
57,664 KB |
testcase_24 | AC | 145 ms
57,604 KB |
testcase_25 | AC | 144 ms
57,588 KB |
testcase_26 | AC | 146 ms
57,636 KB |
testcase_27 | AC | 148 ms
57,632 KB |
testcase_28 | AC | 140 ms
57,552 KB |
testcase_29 | AC | 146 ms
57,576 KB |
testcase_30 | AC | 149 ms
57,204 KB |
testcase_31 | AC | 145 ms
57,232 KB |
ソースコード
public class Main { public static void main(String[] args) { java.io.PrintWriter out = new java.io.PrintWriter(System.out); new Main(out); out.flush(); } /* * 考察 * 連結パーツを作りたい * * 124 * 03x * 03x * 011 * 232 * 44x * を始点パーツ * x13 * 02x * 12x * x00 * x21 * 33x * を接続パーツとすると、良い感じに繋がって3+2xは作れる(最後の列のxを9にすれば終端になる) * 3665 * 244x * 211x * 1000 * 2334 * 655x * で4+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, 4 }, { 1, 2, 4 }, { -1, 0, 0 }, { -1, 2, 1 }, { 3, 3, 4 } }; if (N == 1) out.println("0\n1\n1\n1\n0\n0"); else if (N == 2) out.println(-1); else { int x = (N + 1) % 2, add = 0; int[][] ans = new int[6][N]; add = joint(ans, first[N % 2], 0, add); while ((x += 2) < N - 3) add = joint(ans, joint, x, add); if (x == N - 3) joint(ans, joint, x, add); for (int[] i : ans) { for (int j : i) out.print(j); out.println(); } } } } public int joint(int[][] ans, int[][] block, int first, int add) { for (int y = 0; y < 6; ++y) { for (int x = 0; x < block[y].length; ++x) if (block[y][x] != -1) ans[y][first + x] = (block[y][x] + add) % 10; } return (add + block[0].length * 2 - 1) % 10; } }