結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー どららどらら
提出日時 2021-02-19 22:37:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,444 bytes
コンパイル時間 2,294 ms
コンパイル使用メモリ 165,908 KB
実行使用メモリ 5,404 KB
最終ジャッジ日時 2023-10-15 03:26:24
合計ジャッジ時間 26,763 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 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 2 ms
4,348 KB
testcase_16 AC 21 ms
5,400 KB
testcase_17 AC 21 ms
5,404 KB
testcase_18 AC 20 ms
5,392 KB
testcase_19 AC 22 ms
5,384 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,348 KB
testcase_24 WA -
testcase_25 AC 1 ms
4,352 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,352 KB
testcase_29 WA -
testcase_30 AC 1 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(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(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