結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー どららどらら
提出日時 2021-02-19 23:03:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,160 bytes
コンパイル時間 2,216 ms
コンパイル使用メモリ 170,928 KB
実行使用メモリ 6,308 KB
最終ジャッジ日時 2023-10-16 22:08:55
合計ジャッジ時間 26,987 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 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 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 23 ms
6,308 KB
testcase_17 AC 23 ms
6,308 KB
testcase_18 AC 22 ms
6,308 KB
testcase_19 AC 23 ms
6,308 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
testcase_29 WA -
testcase_30 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int field[1000][1000];

int main(){
  int W, H, X;
  cin >> W >> H >> X;

  if(X == 0){
    rep(i,H){
      rep(j,W){
        cout << 0;
      }
      cout << endl;
    }
  }
  if(W==1 && H==1){
    if(X<=9){
      cout << X << endl;
    }else{
      cout << -1 << endl;
    }
  }
  else if(W==1 && H==2){
    if(X<=18){
      int a, b;
      if(X == 18) a = b = 9;
      else{
        a = X%9;
        b = X - a;
      }
      cout << a << endl;
      cout << b << endl;
    }else{
      cout << -1 << endl;
    }
  }
  else if(W==2 && H==1){
    if(X<=18){
      int a, b;
      if(X == 18) a = b = 9;
      else{
        a = X%9;
        b = X - a;
      }
      cout << a << b << endl;
    }else{
      cout << -1 << endl;
    }
  }
  else if(W==1){
    if(X<=18 && H%3==2){
      int a, b;
      if(X == 18) a = b = 9;
      else{
        a = X%9;
        b = X - a;
      }
      for(int i=0;i<H; i+=3){
        if(i>0) cout << 0 << endl;
        cout << a << endl;
        cout << b << endl;
      }
    }else{
      cout << -1 << endl;
    }
  }
  else if(H==1){
    if(X<=18 && W%3==2){
      int a, b;
      if(X == 18) a = b = 9;
      else{
        a = X%9;
        b = X - a;
      }
      for(int i=0;i<W; i+=3){
        if(i>0) cout << 0;
        cout << a << b;
      }
      cout << endl;
    }else{
      cout << -1 << endl;
    }
  }
  else {
    if(X > 36 || W%3!=2 || H%3!=2){
      cout << -1 << endl;
      return 0;
    }
    
    int a,b,c,d;
    if(X == 36){
      a = b = c = d = 9;
    }else{
      a = X%9;
      b = c = d = (X-a)/3;
    }
    
    for(int i=0; i<H; i+=3){
      for(int j=0; j<W; j+=3){
        field[i][j] = a; field[i][j+1] = b;
        field[i+1][j] = c; field[i+1][j+1] = d;
      }
    }
    
    rep(i,H){
      rep(j,W){
        cout << field[i][j];
      }
      cout << endl;
    }
  }
  
  return 0;
}
0