結果

問題 No.1974 2x2 Flipper
ユーザー 37zigen37zigen
提出日時 2022-06-10 23:22:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,039 bytes
コンパイル時間 2,936 ms
コンパイル使用メモリ 89,172 KB
実行使用メモリ 64,060 KB
最終ジャッジ日時 2023-10-21 05:45:04
合計ジャッジ時間 14,700 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
58,412 KB
testcase_01 AC 254 ms
62,128 KB
testcase_02 WA -
testcase_03 AC 331 ms
64,060 KB
testcase_04 AC 328 ms
63,604 KB
testcase_05 WA -
testcase_06 AC 317 ms
63,568 KB
testcase_07 WA -
testcase_08 AC 278 ms
63,228 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 346 ms
63,608 KB
testcase_12 AC 368 ms
63,604 KB
testcase_13 AC 344 ms
61,704 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 325 ms
63,828 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 332 ms
63,604 KB
testcase_21 AC 368 ms
61,108 KB
testcase_22 WA -
testcase_23 AC 400 ms
63,604 KB
testcase_24 AC 401 ms
61,700 KB
testcase_25 AC 170 ms
60,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main implements Runnable {

	public static void main(String[] args) throws IOException {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
	}
	
	public void run() {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int H=sc.nextInt();
		int W=sc.nextInt();
		if (H%2==0&&W%2==0) {
			System.out.println(H*W);
			for (int i=0;i<H;++i) {
				for (int j=0;j<W;++j) {
					pw.print(1+(j==W-1?"\n":" "));
				}
			}
		} else if (H%2==1&&W%2==1) {
			System.out.println((H*W-Math.max(H, W)));
			for (int i=0;i<H;++i) {
				for (int j=0;j<W;++j) {
					int v=1;
					if (i%Math.min(H, W)==j%Math.min(H, W)) v=0;
					pw.print(v+(j==W-1?"\n":" "));
				}
			}
		} else if (H%2==0 && W%2==1) {
			System.out.println((H*W-H));
			for (int i=0;i<H;++i) {
				for (int j=0;j<W;++j) {
					int v=1;
					if (j==W-1) v=0;
					pw.print(v+(j==W-1?"\n":" "));
				}
			}
		} else {
			System.out.println((H*W-W));
			for (int i=0;i<H;++i) {
				for (int j=0;j<W;++j) {
					int v=1;
					if (i==H-1) v=0;
					pw.print(v+(j==H-1?"\n":" "));
				}
			}
		}
		pw.close();
	}

	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}
0