結果
| 問題 |
No.2256 Step by Step
|
| ユーザー |
CuriousFairy315
|
| 提出日時 | 2023-03-25 04:17:15 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 2,000 ms |
| コード長 | 1,796 bytes |
| コンパイル時間 | 2,313 ms |
| コンパイル使用メモリ | 78,216 KB |
| 実行使用メモリ | 42,352 KB |
| 最終ジャッジ日時 | 2024-09-18 17:56:21 |
| 合計ジャッジ時間 | 7,537 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
ソースコード
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;
}
}
CuriousFairy315