結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー auauaauaua
提出日時 2021-02-19 23:24:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,888 bytes
コンパイル時間 1,797 ms
コンパイル使用メモリ 176,076 KB
実行使用メモリ 9,168 KB
最終ジャッジ日時 2023-10-16 23:20:17
合計ジャッジ時間 28,306 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll inf=INF*INF;
const ll mod=1e9+7;
const ll MAX=140010;



signed main(){
    ll w,h,x;cin>>w>>h>>x;
    vector<vector<ll> >ans(h+1,vector<ll>(w+1));
    if(h==1){
        if(x>18){
            cout<<-1<<endl;
        }else if(x>9){
            vector<ll>ans(w);
            ans[0]=9;
            ans[1]=x-9;
            REP(i,3,w){
                ans[i]=ans[i-3];
            }
            rep(i,w)cout<<ans[i];
            cout<<endl;
        }else{
            vector<ll>ans(w);
            ans[0]=x;
            REP(i,3,w){
                ans[i]=ans[i-3];
            }
            rep(i,w)cout<<ans[i];
            cout<<endl;
        }
    }else if(w==1){
        swap(h,w);
        if(x>18){
            cout<<-1<<endl;
        }else if(x>9){
            vector<ll>ans(w);
            ans[0]=9;
            ans[1]=x-9;
            REP(i,3,w){
                ans[i]=ans[i-3];
            }
            rep(i,w)cout<<ans[i]<<endl;
            cout<<endl;
        }else{
            vector<ll>ans(w);
            ans[0]=x;
            REP(i,3,w){
                ans[i]=ans[i-3];
            }
            rep(i,w)cout<<ans[i]<<endl;
            cout<<endl;
        }
    }else{
        if(x>36){
            cout<<-1<<endl;
        }else{
            vector<vector<ll> >ans(h,vector<ll>(w));
            if(x>9){
                ans[0][0]=9;
                x-=9;
            }else{
                ans[0][0]=x;
                x=0;
            }
            if(x>9){
                ans[1][0]=9;
                x-=9;
            }else{
                ans[1][0]=x;
                x=0;
            }
            if(x>9){
                ans[0][1]=9;
                x-=9;
            }else{
                ans[0][1]=x;
                x=0;
            }
            if(x>9){
                ans[1][1]=9;
                x-=9;
            }else{
                ans[1][1]=x;
                x=0;
            }
            rep(i,2){
                REP(j,3,w){
                    ans[i][j]=ans[i][j-3];
                }
            }
            REP(i,3,h){
                rep(j,w){
                    ans[i][j]=ans[i-3][j];
                }
            }
            rep(i,h){
                rep(j,w){
                    cout<<ans[i][j];
                }
                cout<<endl;
            }
        }
    }
}
0