結果

問題 No.1398 調和の魔法陣 (構築)
ユーザー 沙耶花沙耶花
提出日時 2021-02-19 21:36:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,047 bytes
コンパイル時間 1,994 ms
コンパイル使用メモリ 202,432 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-15 00:07:04
合計ジャッジ時間 24,718 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 WA -
testcase_07 AC 2 ms
4,368 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,372 KB
testcase_11 WA -
testcase_12 AC 2 ms
4,368 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,372 KB
testcase_16 AC 3 ms
4,368 KB
testcase_17 AC 4 ms
4,368 KB
testcase_18 AC 3 ms
4,368 KB
testcase_19 AC 3 ms
4,368 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,368 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,368 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 2 ms
4,372 KB
testcase_29 WA -
testcase_30 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000



int main(){
	
	int W,H,X;
	cin>>W>>H>>X;
	vector<string> ans(H,string(W,'0'));
	
	if(X!=0){
		
		if(H<=2&&W<=2){
			vector<int> cnt(H*W,0);
			rep(i,H*W){
				if(X<=9){
					cnt[i] = X;
					X = 0;
					break;
				}
				else{
					cnt[i] = 9;
					X -= 9;
				}
			}
			
			if(X!=0){
				cout<<-1<<endl;
				return 0;
			}
			else{
				rep(i,H){
					rep(j,W){
						ans[i][j] = '0' + cnt.back();
						cnt.pop_back();
					}
				}
			}
		
		}
		else{
			if(W%3!=2||H%3!=2){
				cout<<-1<<endl;
				return 0;
			}
			
			if(X>36){
				cout<<-1<<endl;
			}
			
			vector<int> cnt(4,0);
			rep(i,4){
				if(X<=9){
					cnt[i] = X;
					break;
				}
				else{
					cnt[i] = 9;
					X -= 9;
				}
			}
			
			
			
			rep(i,H){
				rep(j,W){
					int x = i%3,y = j%3;
					
					if(x<=1&&y<=1){
						ans[i][j] = '0' + (cnt[x*2+y]);
					}
				}
			}
		}
	}
	
	rep(i,H){
		cout<<ans[i]<<endl;
	}
	
    return 0;
}
0