結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー uzzyuzzy
提出日時 2021-02-19 23:30:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,154 bytes
コンパイル時間 1,739 ms
コンパイル使用メモリ 173,084 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-16 23:34:38
合計ジャッジ時間 26,617 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 16 ms
4,348 KB
testcase_17 AC 17 ms
4,348 KB
testcase_18 AC 18 ms
4,348 KB
testcase_19 AC 17 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
testcase_29 WA -
testcase_30 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#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) h = 1;
	if (H == 3) h = 1;
	if ((H + 1) % 3 == 0) h = 2;
	if (W == 1) w = 1;
	if (W == 3) w = 1;
	if ((W + 1) % 3 == 0) w = 2;

	int wh = h * w * 9;
	if (X > wh) {
		co(-1);
		return 0;
	}

	if (H == 1) {
		if (W == 1) co(X);
		else if (W == 3) cout << 0 << X << 0;
		else {
			rep(i, W / 3) cout << X / 2 << (X + 1) / 2 << 0;
			cout << X / 2 << (X + 1) / 2;
		}
		return 0;
	}
	if (H == 3) {
		rep(i, W) cout << 0;
		cout << endl;
		if (W == 1) co(X);
		else if (W == 3) cout << 0 << X << 0;
		else {
			rep(i, W / 3) cout << X / 2 << (X + 1) / 2 << 0;
			cout << X / 2 << (X + 1) / 2;
		}
		rep(i, W) cout << 0;
		cout << endl;
		return 0;
	}
	
	if (W == 1) {
		rep(i, H / 3) {
			co(X / 2);
			co((X + 1) / 2);
			co(0);
		}
		co(X / 2);
		co((X + 1) / 2);
		return 0;
	}

	if (W == 3) {
		rep(i, H / 3) {
			cout << 0 << X / 2 << 0 << endl;
			cout << 0 << (X + 1) / 2 << 0 << endl;
			cout << 0 << 0 << 0 << endl;
		}
		cout << 0 << X / 2 << 0 << endl;
		cout << 0 << (X + 1) / 2 << 0;
		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;
}
0