結果
問題 |
No.1398 調和の魔法陣 (構築)
|
ユーザー |
![]() |
提出日時 | 2021-02-19 23:01:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,007 bytes |
コンパイル時間 | 2,900 ms |
コンパイル使用メモリ | 193,740 KB |
最終ジャッジ日時 | 2025-01-19 01:24:33 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 2 |
ソースコード
#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==1 && w==2 && x<=18) cout<<9<<x-9<<endl; else if(h==2 && w==1 && x<=18){ cout<<9<<endl; cout<<x-9<<endl; } else if(h%3==2 && w%3==2){ int a,b,c,d; if(x<=18) a=9,b=x-9,c=0,d=0; else if(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; } } else if(h%3==2 && w%3==1 && x<=18){ int a=9,b=x-9; 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 cout<<0; } cout<<endl; } } else if(h%3==1 && w%3==2 && x<=18){ int a=9,b=x-9; rep(i,h){ rep(j,w){ if(i%3==0 && j%3==0) cout<<a; else if(i%3==0 && j%3==1) cout<<b; else cout<<0; } cout<<endl; } } else cout<<-1<<endl; } return 0; }