結果
問題 | No.1974 2x2 Flipper |
ユーザー | 37zigen |
提出日時 | 2022-06-10 23:25:06 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,007 bytes |
コンパイル時間 | 3,213 ms |
コンパイル使用メモリ | 89,480 KB |
実行使用メモリ | 63,708 KB |
最終ジャッジ日時 | 2023-10-21 05:45:42 |
合計ジャッジ時間 | 14,967 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge9 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 171 ms
60,188 KB |
testcase_01 | AC | 254 ms
63,204 KB |
testcase_02 | AC | 241 ms
61,120 KB |
testcase_03 | AC | 347 ms
61,532 KB |
testcase_04 | AC | 352 ms
63,516 KB |
testcase_05 | WA | - |
testcase_06 | AC | 325 ms
63,200 KB |
testcase_07 | AC | 339 ms
61,476 KB |
testcase_08 | AC | 274 ms
63,248 KB |
testcase_09 | AC | 361 ms
63,512 KB |
testcase_10 | WA | - |
testcase_11 | AC | 356 ms
63,516 KB |
testcase_12 | AC | 381 ms
63,516 KB |
testcase_13 | AC | 361 ms
63,512 KB |
testcase_14 | AC | 340 ms
61,580 KB |
testcase_15 | AC | 391 ms
61,580 KB |
testcase_16 | WA | - |
testcase_17 | AC | 336 ms
63,300 KB |
testcase_18 | AC | 294 ms
63,608 KB |
testcase_19 | AC | 290 ms
63,612 KB |
testcase_20 | AC | 346 ms
61,676 KB |
testcase_21 | AC | 365 ms
63,464 KB |
testcase_22 | AC | 418 ms
63,516 KB |
testcase_23 | AC | 418 ms
63,512 KB |
testcase_24 | AC | 414 ms
63,512 KB |
testcase_25 | AC | 173 ms
60,192 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(); } }