結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー SSRS
提出日時 2021-02-19 21:34:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 171,308 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-16 17:36:26
合計ジャッジ時間 28,426 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 9 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int W, H, X;
  cin >> W >> H >> X;
  if (X == 0){
    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        cout << 0;
        if (j < W - 1){
          cout << ' ';
        }
      }
      cout << endl;
    }
  } else {
    if (W % 3 != 2 || H % 3 != 2 || X > 36){
      cout << -1 << endl;
    } else {
      vector<vector<int>> a(3, vector<int>(3, 0));
      a[0][0] = X / 4;
      a[0][1] = (X + 1) / 4;
      a[1][0] = (X + 2) / 4;
      a[1][1] = (X + 3) / 4;
      for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
          cout << a[i % 3][j % 3];
          if (j < W - 1){
            cout << ' ';
          }
        }
        cout << endl;
      }
    } 
  }
}
0