結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー 👑 NachiaNachia
提出日時 2021-02-19 21:34:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 3,153 ms
コード長 704 bytes
コンパイル時間 2,373 ms
コンパイル使用メモリ 202,000 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-15 00:04:53
合計ジャッジ時間 30,132 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int W,H,X;
int C[3][3]={};

int main(){
  scanf("%d%d%d",&W,&H,&X);
  vector<int> S;
  while(X>0){ S.push_back(min(X,9)); X-=S.back(); }
  vector<int> PX,PY;
  if(W%3==0) PX={1};
  if(W%3==1) PX={0};
  if(W%3==2) PX={0,1};
  if(H%3==0) PY={1};
  if(H%3==1) PY={0};
  if(H%3==2) PY={0,1};
  if(S.size()>PX.size()*PY.size()) printf("-1\n");
  else{
    while(S.size()<PX.size()*PY.size()) S.push_back(0);
    { int i=0; for(int x:PX) for(int y:PY) C[x][y]=S[i++]; }
    rep(y,H){
      rep(x,W) printf("%d",C[x%3][y%3]);
      printf("\n");
    }
  }
  return 0;
}

0