結果
| 問題 | No.1398 調和の魔法陣 (構築) | 
| コンテスト | |
| ユーザー |  uzzy | 
| 提出日時 | 2021-02-19 23:58:04 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 17 ms / 3,153 ms | 
| コード長 | 3,054 bytes | 
| コンパイル時間 | 1,662 ms | 
| コンパイル使用メモリ | 173,004 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-17 00:17:41 | 
| 合計ジャッジ時間 | 24,630 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W, H, X;
	cin >> W >> H >> X;
	int h = 0, w = 0;
	if ((H + 1) % 3 == 0) h = 2;
	else h = 1;
	if ((W + 1) % 3 == 0) w = 2;
	else w = 1;
	int wh = h * w * 9;
	if (X > wh) {
		co(-1);
		return 0;
	}
	if (H % 3 == 1) {
		rep(i, H / 3) {
			if (W % 3 == 1) {
				rep(j, W / 3) cout << X << 0 << 0;
				co(X);
			}
			else if (W % 3 == 0) {
				rep(j, W / 3) cout << 0 << X << 0;
				cout << endl;
			}
			else {
				rep(j, W / 3) cout << X / 2 << (X + 1) / 2 << 0;
				cout << X / 2 << (X + 1) / 2 << endl;
			}
			rep(j, W) cout << 0;
			cout << endl;
			rep(j, W) cout << 0;
			cout << endl;
		}
		if (W % 3 == 1) {
			rep(j, W / 3) cout << X << 0 << 0;
			co(X);
		}
		else if (W % 3 == 0) {
			rep(j, W / 3) cout << 0 << X << 0;
			cout << endl;
		}
		else {
			rep(j, W / 3) cout << X / 2 << (X + 1) / 2 << 0;
			cout << X / 2 << (X + 1) / 2 << endl;
		}
		return 0;
	}
	if (H % 3 == 0) {
		rep(i, H / 3) {
			rep(j, W) cout << 0;
			cout << endl;
			if (W % 3 == 1) {
				rep(j, W / 3) cout << X << 0 << 0;
				co(X);
			}
			else if (W % 3 == 0) {
				rep(j, W / 3) cout << 0 << X << 0;
				cout << endl;
			}
			else {
				rep(j, W / 3) cout << X / 2 << (X + 1) / 2 << 0;
				cout << X / 2 << (X + 1) / 2 << endl;
			}
			rep(j, W) cout << 0;
			cout << endl;
		}
		return 0;
	}
	
	if (W % 3 == 1) {
		rep(i, H / 3) {
			rep(j, W / 3) cout << X / 2 << 0 << 0;
			co(X / 2);
			rep(j, W / 3) cout << (X + 1) / 2 << 0 << 0;
			co((X + 1) / 2);
			rep(j, W) cout << 0;
			cout << endl;
		}
		rep(j, W / 3) cout << X / 2 << 0 << 0;
		co(X / 2);
		rep(j, W / 3) cout << (X + 1) / 2 << 0 << 0;
		co((X + 1) / 2);
		return 0;
	}
	if (W % 3 == 0) {
		rep(i, H / 3) {
			rep(j, W / 3) cout << 0 << X / 2 << 0;
			cout << endl;
			rep(j, W / 3) cout << 0 << (X + 1) / 2 << 0;
			cout << endl;
			rep(j, W) cout << 0;
			cout << endl;
		}
		rep(j, W / 3) cout << 0 << X / 2 << 0;
		cout << endl;
		rep(j, W / 3) cout << 0 << (X + 1) / 2 << 0;
		cout << endl;
		return 0;
	}
	int a = X / 4;
	int b = (X + 1) / 4;
	int c = (X + 2) / 4;
	int d = (X + 3) / 4;
	rep(i, H / 3) {
		rep(j, W / 3) {
			cout << a << b << 0;
		}
		cout << a << b << endl;
		rep(j, W / 3) {
			cout << c << d << 0;
		}
		cout << c << d << endl;
		rep(j, W) cout << 0;
		cout << endl;
	}
	rep(j, W / 3) {
		cout << a << b << 0;
	}
	cout << a << b << endl;
	rep(j, W / 3) {
		cout << c << d << 0;
	}
	cout << c << d << endl;
	Would you please return 0;
}
            
            
            
        