結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー Example0911
提出日時 2021-02-20 08:53:27
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,130 bytes
コンパイル時間 1,816 ms
コンパイル使用メモリ 198,944 KB
最終ジャッジ日時 2025-01-19 02:34:12
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int W, H, X; cin >> W >> H >> X;
	vector<vector<ll>>ans(3, vector<ll>(3));
	for (int i = 0; i <= 9; i++) {
		for (int j = 0; j <= 9; j++) {
			for (int k = 0; k <= 9; k++) {
				for (int l = 0; l <= 9; l++) {
					bool ok = true;
					ans[0][0] = i, ans[0][1] = j, ans[1][0] = k, ans[1][1] = l;
					for (int a = 0; a < 3; a++) {
						for (int b = 0; b < 3; b++) {
							int now = 0;
							for (int da = -1; da <= 1; da++) {
								for (int db = -1; db <= 1; db++) {
									int na = a + da, nb = b + db;
									if (0 <= na && na < 3 && 0 <= nb && nb < 3) {
										now += ans[na][nb];
									}
								}
							}
							if (now != X) {
								ok = false;
							}
						}
					}
					if (ok) {
						for (int a = 0; a < H; a++) {
							for (int b = 0; b < W; b++) {
								cout << ans[a % 3][b % 3];
							}
							cout << endl;
						}
						return 0;
					}
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}
0