結果
| 問題 |
No.1398 調和の魔法陣 (構築)
|
| コンテスト | |
| ユーザー |
sten_san
|
| 提出日時 | 2021-02-19 23:08:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 3,153 ms |
| コード長 | 4,383 bytes |
| コンパイル時間 | 2,278 ms |
| コンパイル使用メモリ | 194,920 KB |
| 最終ジャッジ日時 | 2025-01-19 01:32:30 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
struct iofast_t {
iofast_t() {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
}
} iofast;
struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
return vec(Element(), arg, args...);
}
int main() {
int w, h, x; cin >> w >> h >> x;
int n = (w % 3 == 0 ? 1 : w % 3) * (h % 3 == 0 ? 1 : h % 3);
if (x < n || n * 9 < x) {
cout << -1 << endl;
return 0;
}
if (w % 3 == 0 && h % 3 == 0) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 != 1 || j % 3 != 1) {
cout << 0;
continue;
}
cout << x;
}
cout << endl;
}
}
if (w % 3 == 1 && h % 3 == 0) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 != 1 || j % 3 != 0) {
cout << 0;
continue;
}
cout << x;
}
cout << endl;
}
}
if (w % 3 == 2 && h % 3 == 0) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 != 1 || j % 3 == 2) {
cout << 0;
continue;
}
if (j % 3 == 0) {
cout << x / 2;
continue;
}
cout << (x + 1) / 2;
}
cout << endl;
}
}
if (w % 3 == 0 && h % 3 == 1) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 != 0 || j % 3 != 1) {
cout << 0;
continue;
}
cout << x;
}
cout << endl;
}
}
if (w % 3 == 1 && h % 3 == 1) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 != 0 || j % 3 != 0) {
cout << 0;
continue;
}
cout << x;
}
cout << endl;
}
}
if (w % 3 == 2 && h % 3 == 1) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 != 0 || j % 3 == 2) {
cout << 0;
continue;
}
if (j % 3 == 0) {
cout << x / 2;
continue;
}
cout << (x + 1) / 2;
}
cout << endl;
}
}
if (w % 3 == 0 && h % 3 == 2) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 == 2 || j % 3 != 1) {
cout << 0;
continue;
}
if (i % 3 == 0) {
cout << x / 2;
continue;
}
cout << (x + 1) / 2;
}
cout << endl;
}
}
if (w % 3 == 1 && h % 3 == 2) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 == 2 || j % 3 != 0) {
cout << 0;
continue;
}
if (i % 3 == 0) {
cout << x / 2;
continue;
}
cout << (x + 1) / 2;
}
cout << endl;
}
}
if (w % 3 == 2 && h % 3 == 2) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (i % 3 == 2 || j % 3 == 2) {
cout << 0;
continue;
}
if (i % 3 == 0 || j % 3 == 0) {
cout << x / 4;
continue;
}
cout << (x - x / 4 * 3);
}
cout << endl;
}
}
}
sten_san