結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー |
![]() |
提出日時 | 2021-02-20 08:51:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,130 bytes |
コンパイル時間 | 2,274 ms |
コンパイル使用メモリ | 197,072 KB |
最終ジャッジ日時 | 2025-01-19 02:32:53 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 WA * 15 |
ソースコード
#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 i = 0; i < H; i++) {for (int j = 0; j < W; j++) {cout << ans[i % 3][j % 3];}cout << endl;}return 0;}}}}}cout << -1 << endl;return 0;}