結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー 蜜蜂蜜蜂
提出日時 2021-02-19 21:44:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,179 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 165,700 KB
実行使用メモリ 5,040 KB
最終ジャッジ日時 2023-10-15 00:36:14
合計ジャッジ時間 27,373 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 28 ms
4,912 KB
testcase_07 AC 3 ms
4,740 KB
testcase_08 AC 28 ms
4,724 KB
testcase_09 WA -
testcase_10 AC 4 ms
4,736 KB
testcase_11 WA -
testcase_12 AC 4 ms
5,004 KB
testcase_13 AC 27 ms
4,716 KB
testcase_14 AC 27 ms
5,028 KB
testcase_15 AC 8 ms
4,712 KB
testcase_16 AC 27 ms
4,796 KB
testcase_17 AC 27 ms
4,788 KB
testcase_18 AC 27 ms
4,840 KB
testcase_19 AC 27 ms
4,784 KB
testcase_20 AC 2 ms
4,372 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 8 ms
4,752 KB
testcase_24 WA -
testcase_25 AC 3 ms
4,784 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 3 ms
4,724 KB
testcase_29 WA -
testcase_30 AC 4 ms
4,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;
using ld = long double;
#define fi first
#define se second
#define pb push_back

int main(){
  int w,h,x,copyx;
  cin>>w>>h>>x;
  copyx=x;
  if(x>36){
    cout<<-1<<endl;
    return 0;
  }
  int ans[h][w]={};
  int p[4];
  for(int i=0;i<4;i++){
    if(x>=9){
      p[i]=9;
      x-=9;
    }
    else{
      p[i]=x;
      x=0;
    }
  }
  x=copyx;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i%3==0){
        if(j%3==0){
          ans[i][j]=p[0];
        }
        if(j%3==1){
          ans[i][j]=p[1];
        }
      }
      if(i%3==1){
        if(j%3==0){
          ans[i][j]=p[2];
        }
        if(j%3==1){
          ans[i][j]=p[3];
        }
      }
    }
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int s=0;
      for(int k=i-1;k<=i+1;k++){
        for(int l=j-1;l<=j+1;l++){
          if(k<0||k>=h||l<0||l>=w){
            continue;
          }
          s+=ans[k][l];
        }
      }
      if(s!=x){
        cout<<-1<<endl;
        return 0;
      }
    }
  }
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<ans[i][j];
    }
    cout<<endl;
  }
}
0