結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー snow39snow39
提出日時 2021-02-19 21:59:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,392 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 95,568 KB
実行使用メモリ 4,540 KB
最終ジャッジ日時 2023-10-15 01:31:35
合計ジャッジ時間 26,594 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int W,H,X;
  cin>>W>>H>>X;

  vector<vector<int>> A(H,vector<int> (W,0));
  for(int a=0;a<=9;a++) for(int b=0;b<=9;b++){
    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
      A[i][j]=0;
      if(i%3==0){
        if(j%3==0) A[i][j]=a;
        if(j%3==1) A[i][j]=b;
      }else if(j%3==1){
        if(j%3==0) A[i][j]=b;
        if(j%3==1) A[i][j]=a;
      }
    }

    bool ng=false;
    for(int i=0;i<H;i++) for(int j=0;j<W;j++){
      int res=0;
      for(int k=-1;k<=1;k++) for(int l=-1;l<=1;l++){
        int nx=i+k;
        int ny=j+l;
        if(nx<0||ny<0||nx>=H||ny>=W) continue;
        res+=A[nx][ny];
      }
      if(res!=X){
        ng=true;
        break;
      }
    }

    if(ng) continue;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++) cout<<A[i][j];
      cout<<"\n";
    }
    return 0;
  }

  cout<<-1<<"\n";

  return 0;
}
0