結果
問題 | No.1974 2x2 Flipper |
ユーザー | 37zigen |
提出日時 | 2022-06-10 23:25:06 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,007 bytes |
コンパイル時間 | 2,229 ms |
コンパイル使用メモリ | 87,812 KB |
実行使用メモリ | 47,436 KB |
最終ジャッジ日時 | 2024-09-21 06:53:29 |
合計ジャッジ時間 | 12,808 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 156 ms
42,796 KB |
testcase_01 | AC | 236 ms
46,312 KB |
testcase_02 | AC | 222 ms
43,408 KB |
testcase_03 | AC | 303 ms
47,248 KB |
testcase_04 | AC | 311 ms
47,228 KB |
testcase_05 | WA | - |
testcase_06 | AC | 293 ms
46,476 KB |
testcase_07 | AC | 315 ms
47,348 KB |
testcase_08 | AC | 256 ms
45,800 KB |
testcase_09 | AC | 325 ms
47,404 KB |
testcase_10 | WA | - |
testcase_11 | AC | 308 ms
47,052 KB |
testcase_12 | AC | 333 ms
47,348 KB |
testcase_13 | AC | 307 ms
47,436 KB |
testcase_14 | AC | 300 ms
47,080 KB |
testcase_15 | AC | 329 ms
47,216 KB |
testcase_16 | WA | - |
testcase_17 | AC | 300 ms
47,052 KB |
testcase_18 | AC | 245 ms
46,696 KB |
testcase_19 | AC | 262 ms
46,392 KB |
testcase_20 | AC | 310 ms
47,228 KB |
testcase_21 | AC | 318 ms
47,336 KB |
testcase_22 | AC | 359 ms
47,332 KB |
testcase_23 | AC | 365 ms
47,376 KB |
testcase_24 | AC | 375 ms
47,360 KB |
testcase_25 | AC | 150 ms
42,596 KB |
ソースコード
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) { pw.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) { pw.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) { pw.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 { pw.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==W-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(); } }