結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー milanis48663220
提出日時 2021-02-19 21:52:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 3,153 ms
コード長 2,948 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 92,828 KB
最終ジャッジ日時 2025-01-18 23:48:25
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
int w, h, x; cin >> w >> h >> x;
if(w%3 == 2 && h%3 == 2){
if(x <= 36){
vector<int> v(4);
for(int i = 0; i < 4; i++){
v[i] = x/4+(x%4 > i ? 1 : 0);
}
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(i%3 != 2 && j%3 != 2){
int idx = (i%3)*2+(j%3);
cout << v[idx];
}else{
cout << 0;
}
}
cout << endl;
}
}else{
cout << -1 << endl;
}
}else if(w%3 == 2){
if(x <= 18){
vector<int> v(2);
for(int i = 0; i < 2; i++){
v[i] = x/2+(x%2 > i ? 1 : 0);
}
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(i%3 != 2 && i%3 != h%3 && j%3 != 2){
int idx = (j%3);
cout << v[idx];
}else{
cout << 0;
}
}
cout << endl;
}
}else{
cout << -1 << endl;
}
}else if(h%3 == 2){
if(x <= 18){
vector<int> v(2);
for(int i = 0; i < 2; i++){
v[i] = x/2+(x%2 > i ? 1 : 0);
}
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(i%3 != 2 && j%3 != 2 && j%3 != w%3){
int idx = (i%3);
cout << v[idx];
}else{
cout << 0;
}
}
cout << endl;
}
}else{
cout << -1 << endl;
}
}else{
if(x <= 9){
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(i%3 != 2 && i%3 != h%3 && j%3 != 2 && j%3 != w%3){
cout << x;
}else{
cout << 0;
}
}
cout << endl;
}
}else{
cout << -1 << endl;
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0