結果
| 問題 |
No.1398 調和の魔法陣 (構築)
|
| コンテスト | |
| ユーザー |
蜜蜂
|
| 提出日時 | 2021-02-19 21:52:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,349 bytes |
| コンパイル時間 | 1,659 ms |
| コンパイル使用メモリ | 168,600 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-16 18:39:35 |
| 合計ジャッジ時間 | 26,588 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
if(h==3&&w==3){
if(x>9){
cout<<-1<<endl;
return 0;
}
cout<<"000"<<endl;
cout<<0<<x<<0<<endl;
cout<<"000"<<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;
}
}
蜜蜂