結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー umezoumezo
提出日時 2021-02-19 22:48:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,505 bytes
コンパイル時間 2,445 ms
コンパイル使用メモリ 199,092 KB
実行使用メモリ 4,476 KB
最終ジャッジ日時 2023-10-15 03:51:16
合計ジャッジ時間 28,530 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

int main(){
  int w,h,x;
  cin>>w>>h>>x;

  if(x>36) cout<<-1<<endl;
  else if(x<=9){
    if(w%3==1 && h%3==1){
      rep(i,h){
        rep(j,w){
          if(i%3==0 && j%3==0) cout<<x;
          else cout<<0;
        }
        cout<<endl;
      }
    }
    else if(w%3==1){
      rep(i,h){
        rep(j,w){
          if(i%3==1 && j%3==0) cout<<x;
          else cout<<0;
        }
        cout<<endl;
      }
    }
    else if(h%3==1){
      rep(i,h){
        rep(j,w){
          if(i%3==0 && j%3==1) cout<<x;
          else cout<<0;
        }
        cout<<endl;
      }
    }
    else{
      rep(i,h){
        rep(j,w){
          if(i%3==1 && j%3==1) cout<<x;
          else cout<<0;
        }
        cout<<endl;
      }
    }
  }
  else{
    if(h==1 && w==2 && x<=18) cout<<9<<x-9<<endl;
    else if(h==2 && w==1 && x<=18){
      cout<<9<<endl;
      cout<<x-9<<endl;
    }
    else if(h%3!=2 || w%3!=2) cout<<-1<<endl;
    else{
      int a,b,c,d;
      if(x<=18) a=9,b=x-9,c=0,d=0;
      else if(x<=27) a=9,b=9,c=x-18,d=0;
      else a=9,b=9,c=9,d=x-27;
      rep(i,h){
        rep(j,w){
          if(i%3==0 && j%3==0) cout<<a;
          else if(i%3==1 && j%3==0) cout<<b;
          else if(i%3==0 && j%3==1) cout<<c;
          else if(i%3==1 && j%3==1) cout<<d;
          else cout<<0;
        }
        cout<<endl;
      }
    }
  }

  return 0;
}
0