結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー umezoumezo
提出日時 2021-02-19 23:12:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,359 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 203,960 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-16 22:52:24
合計ジャッジ時間 28,405 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 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,348 KB
testcase_06 AC 22 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 22 ms
4,348 KB
testcase_09 AC 23 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 23 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 23 ms
4,348 KB
testcase_14 AC 23 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 22 ms
4,348 KB
testcase_17 AC 22 ms
4,348 KB
testcase_18 AC 22 ms
4,348 KB
testcase_19 AC 23 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 23 ms
4,348 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 22 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 22 ms
4,348 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 22 ms
4,348 KB
testcase_30 AC 2 ms
4,348 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%3==2 && w%3==2){
      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;
      }
    }
    else if(h%3==2 && w%3==1 && x<=18){
      int a=9,b=x-9;
       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 cout<<0;
        }
        cout<<endl;
      }
    }
    else if(h%3==1 && w%3==2 && x<=18){
      int a=9,b=x-9;
       rep(i,h){
        rep(j,w){
          if(i%3==0 && j%3==0) cout<<a;
          else if(i%3==0 && j%3==1) cout<<b;
          else cout<<0;
        }
        cout<<endl;
      }
    }
    else if(h==2 && w%3==0 && x<=18){
      int a=9,b=x-9;
       rep(i,h){
        rep(j,w){
          if(i%3==0 && j%3==1) cout<<a;
          else if(i%3==1 && j%3==1) cout<<b;
          else cout<<0;
        }
        cout<<endl;
      }
    }
    else if(h%3==0 && w==2 && x<=18){
      int a=9,b=x-9;
       rep(i,h){
        rep(j,w){
          if(i%3==1 && j%3==0) cout<<a;
          else if(i%3==1 && j%3==1) cout<<b;
          else cout<<0;
        }
        cout<<endl;
      }
    }
    else cout<<-1<<endl;
  }
  

  return 0;
}
0