結果
| 問題 |
No.1398 調和の魔法陣 (構築)
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2021-02-19 22:38:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,379 bytes |
| コンパイル時間 | 2,770 ms |
| コンパイル使用メモリ | 192,820 KB |
| 最終ジャッジ日時 | 2025-01-19 00:54:21 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 6 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main(){
int w,h,x;
cin>>w>>h>>x;
if(x>36) cout<<-1<<endl;
else if(x<=9){
if(w%3==1 && h%3==1){
rep(i,h){
rep(j,w){
if(i%3==0 && j%3==0) cout<<x;
else cout<<0;
}
cout<<endl;
}
}
else if(w%3==1){
rep(i,h){
rep(j,w){
if(i%3==1 && j%3==0) cout<<x;
else cout<<0;
}
cout<<endl;
}
}
else if(h%3==1){
rep(i,h){
rep(j,w){
if(i%3==0 && j%3==1) cout<<x;
else cout<<0;
}
cout<<endl;
}
}
else{
rep(i,h){
rep(j,w){
if(i%3==1 && j%3==1) cout<<x;
else cout<<0;
}
cout<<endl;
}
}
}
else{
if(h%3!=2 || w%3!=2) cout<<-1<<endl;
else{
int a,b,c,d;
if(x>9 && x<=18) a=9,b=x-9,c=0,d=0;
else if(x>18 && x<=27) a=9,b=9,c=x-18,d=0;
else a=9,b=9,c=9,d=x-27;
rep(i,h){
rep(j,w){
if(i%3==0 && j%3==0) cout<<a;
else if(i%3==1 && j%3==0) cout<<b;
else if(i%3==0 && j%3==1) cout<<c;
else if(i%3==1 && j%3==1) cout<<d;
else cout<<0;
}
cout<<endl;
}
}
}
return 0;
}
umezo