結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー norikamenorikame
提出日時 2021-02-19 22:16:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 3,153 ms
コード長 1,802 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 203,912 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-15 02:24:34
合計ジャッジ時間 26,212 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

using ll = long long;
using ull = unsigned long long;
#define v(t) vector<t>
#define p(t) pair<t, t>
#define p2(t, s) pair<t, s>
#define vp(t) v(p(t))

#define rep(i, n) for (int i=0,i##_len=((int)(n)); i<i##_len; ++i)
#define rep2(i, a, n) for (int i=((int)(a)),i##_len=((int)(n)); i<=i##_len; ++i)
#define repr(i, n) for (int i=((int)(n)-1); i>=0; --i)
#define rep2r(i, a, n) for (int i=((int)(n)),i##_len=((int)(a)); i>=i##_len; --i)

#define repi(itr, c) for (__typeof((c).begin()) itr=(c).begin(); itr!=(c).end(); ++itr)
#define repir(itr, c) for (__typeof((c).rbegin()) itr=(c).rbegin(); itr!=(c).rend(); ++itr)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define eb emplace_back

#define INF (1e9)
#define LINF (1e18)
#define PI (acos(-1))
#define EPS (1e-7)
#define DEPS (1e-10)

int main(){
    int w, h, x;
    cin >> w >> h >> x;
    int mcnt = max(1,w%3) * max(1,h%3);
    if (x > mcnt*9) {
        cout << -1 << endl;
        return 0;
    }
    v(string) ans(h, string(w, '0')), s1(3, string(3, '0'));
    char n1 = (char)((x/mcnt)+1+'0');
    int cmd = x % mcnt, ncnt = 0;
    const v(int) lval = { 2, 1, 1 }, rval = { 2, 1, 2 };
    int l = lval[w%3], r = rval[w%3], u = lval[h%3], d = rval[h%3];
    rep(i, 3) rep(j, 3) {
        if (i>=u&&i<=d && j>=l&&j<=r) {
            ++ncnt;
            char tc = (ncnt<=cmd)?n1:(n1-1);
            s1[i][j] = tc;
        }
    }
    rep(i, h) rep(j, w) ans[i][j] = s1[(i+1)%3][(j+1)%3];
    rep(i, h) cout << ans[i] << endl;
    return 0;
}
0