結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー N_N_MochiN_N_Mochi
提出日時 2021-02-19 21:58:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 3,153 ms
コード長 1,637 bytes
コンパイル時間 7,969 ms
コンパイル使用メモリ 324,040 KB
実行使用メモリ 6,300 KB
最終ジャッジ日時 2023-09-07 23:03:33
合計ジャッジ時間 34,019 ms
ジャッジサーバーID
(参考情報)
judge5 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 26 ms
6,024 KB
testcase_07 AC 6 ms
6,300 KB
testcase_08 AC 26 ms
6,008 KB
testcase_09 AC 26 ms
6,216 KB
testcase_10 AC 7 ms
6,220 KB
testcase_11 AC 26 ms
6,064 KB
testcase_12 AC 6 ms
6,024 KB
testcase_13 AC 26 ms
6,024 KB
testcase_14 AC 26 ms
6,088 KB
testcase_15 AC 6 ms
6,008 KB
testcase_16 AC 26 ms
6,068 KB
testcase_17 AC 26 ms
6,052 KB
testcase_18 AC 26 ms
6,124 KB
testcase_19 AC 26 ms
6,012 KB
testcase_20 AC 6 ms
6,100 KB
testcase_21 AC 26 ms
6,012 KB
testcase_22 AC 25 ms
6,068 KB
testcase_23 AC 6 ms
6,052 KB
testcase_24 AC 27 ms
6,064 KB
testcase_25 AC 6 ms
6,072 KB
testcase_26 AC 26 ms
6,028 KB
testcase_27 AC 26 ms
6,080 KB
testcase_28 AC 6 ms
6,132 KB
testcase_29 AC 26 ms
6,008 KB
testcase_30 AC 6 ms
6,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = (ll)(a - 1); i >= (ll)(b); i--)
#define rrep(i, a) rFOR(i, a, 0)
#define all(c) begin(c),end(c)
using namespace std;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W,X;
    cin >> W >> H >> X;
    vvl ans(H,vl(W,-1));
    rep(i,H){
        rep(j,W){
            if(i%3==2||j%3==2||(H-1-i)%3==2||(W-1-j)%3==2) ans[i][j]=0;
        }
    }
    int cnt=0;
    rep(i,min(H,3)){
        rep(j,min(W,3)){
            if(ans[i][j]==-1) cnt++;
        }
    }
    if(cnt*9<X){
        cout << -1 << endl;
        return 0;
    }
    rep(i,min(H,3)){
        rep(j,min(W,3)){
            if(ans[i][j]==-1){
                ans[i][j]=min(9,X);
                X-=ans[i][j];
            }
        }
    }
    rep(i,H){
        rep(j,W){
            ans[i][j]=ans[i%3][j%3];
        }
    }
    rep(i,H){
        rep(j,W){
            cout << ans[i][j];
        }
        cout << endl;
    }
}
0