結果
問題 |
No.1398 調和の魔法陣 (構築)
|
ユーザー |
![]() |
提出日時 | 2021-02-19 21:44:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,179 bytes |
コンパイル時間 | 1,693 ms |
コンパイル使用メモリ | 168,536 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-16 18:09:30 |
合計ジャッジ時間 | 27,866 ms |
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define fi first #define se second #define pb push_back int main(){ int w,h,x,copyx; cin>>w>>h>>x; copyx=x; if(x>36){ cout<<-1<<endl; return 0; } int ans[h][w]={}; int p[4]; for(int i=0;i<4;i++){ if(x>=9){ p[i]=9; x-=9; } else{ p[i]=x; x=0; } } x=copyx; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(i%3==0){ if(j%3==0){ ans[i][j]=p[0]; } if(j%3==1){ ans[i][j]=p[1]; } } if(i%3==1){ if(j%3==0){ ans[i][j]=p[2]; } if(j%3==1){ ans[i][j]=p[3]; } } } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ int s=0; for(int k=i-1;k<=i+1;k++){ for(int l=j-1;l<=j+1;l++){ if(k<0||k>=h||l<0||l>=w){ continue; } s+=ans[k][l]; } } if(s!=x){ cout<<-1<<endl; return 0; } } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout<<ans[i][j]; } cout<<endl; } }