結果
問題 | No.1398 調和の魔法陣 (構築) |
ユーザー |
![]() |
提出日時 | 2021-02-19 21:41:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 3,153 ms |
コード長 | 1,436 bytes |
コンパイル時間 | 886 ms |
コンパイル使用メモリ | 64,512 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 18:01:13 |
合計ジャッジ時間 | 28,369 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <iostream> using namespace std; int b[3][3]; int main() { int w, h, x; cin >> w >> h >> x; if(h % 3 == 2 && w % 3 == 2){ if(x > 36){ cout << -1 << endl; return 0; } for(int i = 0; i < 2; i++){ for(int j = 0; j < 2; j++){ b[i][j] = min(9, x); x -= b[i][j]; } } } else if(h % 3 == 2){ if(x > 18){ cout << -1 << endl; return 0;; } for(int i = 0; i < 2; i++){ if(w % 3 == 1){ b[i][0] = min(9, x); x -= b[i][0]; } else{ b[i][1] = min(9, x); x -= b[i][1]; } } } else if(w % 3 == 2){ if(x > 18){ cout << -1 << endl; return 0; } for(int j = 0; j < 2; j++){ if(h % 3 == 1){ b[0][j] = min(9, x); x -= b[0][j]; } else{ b[1][j] = min(9, x); x -= b[1][j]; } } } else{ if(x > 9){ cout << -1 << endl; return 0; } int i = 1 - h % 3; int j = 1 - w % 3; b[i][j] = x; } for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++) cout << b[i % 3][j % 3]; cout << endl; } }