結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー ShibuyapShibuyap
提出日時 2021-02-19 22:55:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,093 bytes
コンパイル時間 2,367 ms
コンパイル使用メモリ 200,740 KB
実行使用メモリ 5,572 KB
最終ジャッジ日時 2023-10-15 04:06:25
合計ジャッジ時間 28,646 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

int main() {
    int w, h, x;
    cin >> w >> h >> x;
    if(x > 36){
        cout << -1 << endl;
        return 0;
    }

    if(x == 0){
        rep(i,h){
            rep(j,w){
                cout << '0';
            }
            cout << endl;
        }
        return 0;
    }

    int f[h+100][w+100];
    rep(i,h+100){
        rep(j,w+100){
            f[i][j] = 0;
        }
    }

    rep(a,10){
        rep(b,10){
            rep(c,10){
                rep(d,10){
                    int hh = min(h,10);
                    int ww = min(w,10);
                    rep(i,hh){
                        rep(j,ww){
                            if(i%3==0&&j%3==0){
                                f[i][j] = a;
                            }
                            if(i%3==0&&j%3==1){
                                f[i][j] = b;
                            }
                            if(i%3==1&&j%3==0){
                                f[i][j] = c;
                            }
                            if(i%3==1&&j%3==1){
                                f[i][j] = d;
                            }
                        }
                    }
                    int ok = 1;
                    rep(i,hh){
                        rep(j,ww){
                            int sum = 0;
                            srep(k,-1,2){
                                srep(l,-1,2){
                                    if(i+k>=0&&j+l>=0){
                                        sum += f[i+k][j+l];
                                    }
                                }
                            }
                            if(sum != x){
                                ok = 0;
                                break;
                            }
                        }
                        if(ok == 0) break;
                    }
                    if(ok){
                        rep(i,h){
                            rep(j,w){
                                if(i%3==0&&j%3==0){
                                    f[i][j] = a;
                                }
                                if(i%3==0&&j%3==1){
                                    f[i][j] = b;
                                }
                                if(i%3==1&&j%3==0){
                                    f[i][j] = c;
                                }
                                if(i%3==1&&j%3==1){
                                    f[i][j] = d;
                                }
                                cout << f[i][j];
                            }
                            cout << endl;
                        }
                        return 0;
                    }
                }
            }
        }
    }
    
    cout << -1 << endl;
    return 0;
}
 
 
0