結果
| 問題 |
No.1398 調和の魔法陣 (構築)
|
| コンテスト | |
| ユーザー |
tkmst201
|
| 提出日時 | 2021-02-22 11:05:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,822 bytes |
| コンパイル時間 | 2,301 ms |
| コンパイル使用メモリ | 200,080 KB |
| 最終ジャッジ日時 | 2025-01-19 03:22:27 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 1 WA * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//
int main() {
int W, H, X;
cin >> W >> H >> X;
vector<vector<int>> ans;
if (X == 0) ans.assign(H, vector(W, 0));
if (X <= 9) {
if (X % 2 == 0 && H % 2 == 0) {
ans.assign(H, vector(W, 0));
REP(i, H) REP(j, W) if (i % 3 == 0 && j % 3 == 0) ans[i][j] = X;
}
}
if (X <= 18) {
int a, b;
if (X >= 9) a = 9, b = X - 9;
else a = X, b = 0;
ans.assign(H, vector(W, 0));
if (W % 2 == 0 && H % 3 == 2) {
REP(i, H) REP(j, W) {
if (i % 3 == 0 && j % 3 == 0) ans[i][j] = a;
if (i % 3 == 1 && j % 3 == 0) ans[i][j] = b;
}
}
else if (H % 2 == 0 && W % 3 == 2) {
REP(i, H) REP(j, W) {
if (i % 3 == 0 && j % 3 == 0) ans[i][j] = a;
if (i % 3 == 0 && j % 3 == 1) ans[i][j] = b;
}
}
}
if (X <= 36) {
ans.assign(H, vector(W, 0));
int x[2][2] {};
REP(i, 10) REP(j, 10) REP(k, 10) {
int s = i + j + k;
if (s <= X && X - s <= 9) {
x[0][0] = i;
x[0][1] = j;
x[1][0] = k;
x[1][1] = X - s;
}
}
if (H % 3 == 2 && W % 3 == 2) {
REP(i, H) REP(j, W) {
if (i % 3 == 2 || j % 3 == 2) continue;
ans[i][j] = x[i % 3][j % 3];
}
}
}
if (ans.empty()) puts("-1");
else REP(i, H) REP(j, W) printf("%d%c", ans[i][j], " \n"[j + 1 == W]);
}
tkmst201