結果
| 問題 |
No.1974 2x2 Flipper
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2022-06-13 11:24:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 98 ms / 2,000 ms |
| コード長 | 1,137 bytes |
| コンパイル時間 | 377 ms |
| コンパイル使用メモリ | 43,392 KB |
| 実行使用メモリ | 7,000 KB |
| 最終ジャッジ日時 | 2024-09-25 04:52:52 |
| 合計ジャッジ時間 | 4,605 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1974.cc: No.1974 2x2 Flipper - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_H = 1000;
const int MAX_W = 1000;
/* typedef */
/* global variables */
int as[MAX_H][MAX_W];
/* subroutines */
void printans(int h, int w, int c) {
printf("%d\n", c);
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
printf("%d%c", as[i][j], (j + 1 < w) ? ' ' : '\n');
}
/* main */
int main() {
int h, w;
scanf("%d%d", &h, &w);
int c = 0;
if (h > 1 && w > 1 && (h & w & 1)) {
for (int i = 0; i < h; i++) fill(as[i], as[i] + w, 1);
c = h * w;
if (h <= w) {
for (int y = 0, x = 0, d = 1; x < w;) {
for (int i = 0; i < d; i++) as[y][x++] = 0, c--;
if (++y >= h) y = 0, d = 2;
}
}
else {
for (int x = 0, y = 0, d = 1; y < h;) {
for (int i = 0; i < d; i++) as[y++][x] = 0, c--;
if (++x >= w) x = 0, d = 2;
}
}
}
else {
int he = h & ~1, we = w & ~1;
for (int i = 0; i < he; i++)
for (int j = 0; j < we; j++) as[i][j] = 1, c++;
}
printans(h, w, c);
return 0;
}
tnakao0123