結果
| 問題 |
No.1434 Make Maze
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2021-03-19 23:36:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 5,175 bytes |
| コンパイル時間 | 1,087 ms |
| コンパイル使用メモリ | 97,904 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-19 02:20:01 |
| 合計ジャッジ時間 | 5,293 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 WA * 4 RE * 6 |
ソースコード
//author:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic
//せんげん!
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <cctype>
#include <utility>
#include <climits>
//なまえくーかん!
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//てーすう!
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);
//でふぁいん!
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)
//みじかく!
#define pb push_back
#define fir first
#define scn second
#define ednl endl
//いぇすのー!
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")
//きんぼーnほーこー!!
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
__attribute__((constructor))
void initial() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int main(){
int h,w,x;cin>>h>>w>>x;
char a[h][w];
for(int i = 0; h > i; i++){
for(int j = 0; w > j; j++){
int I = i+1,J = j+1;
if((I%2) && (J%2)){
a[i][j] = '.';
}else if((!(I%2)) && (!(J%2))){
a[i][j] = '#';
}else{
a[i][j] = '.';
}
}
}
//必要数
int wan = ((h-1)/2)*((w-1)/2);
//最大値
int nun = h*(w/2+1)+w/2;
if((x-(h+w-1)+1)%4 || x<(h+w-1)-1 || x>nun){
cout << -1 << endl;
}else{
//3,7,11...は偶数列なので(頭が)バグるため、奇数列を元に考えるのが得策
if((!((h+1)%4)) && (!((w+1)%4)) ){
//偶数列しかない場合
for(int i = 3; w > i; i+=4){
for(int j = 2; h > j; j+=2){
a[j][i] = '#';
}
}
int mv = (x-(h+w-1)+1)/4;
int i = 1;
for(; w-2 > i; i+=4){
if(h/2 <= mv){
for(int j = 0; h-2 > j; j+=2){
a[j][i] = '#';
mv--;
}
}else if(mv){
int j = 0;
for(;h > j && mv;j+=2){
a[j][i] = '#';
mv--;
}
j+=2;
for(;w > j; j+=2){
a[j][i] = '#';
}
}else{
for(int j = 2; h > j; j+=2){
a[j][i] = '#';
}
}
}
if(mv){
//3*hの形にする
for(int I = 1; h > I; I+=4){
a[I][w-3] = '#';
}
for(int I = 3; h > I; I+=4){
if(mv){
a[I][w-1] = '#';
}
}
}else{
if(h/2 <= mv){
for(int j = 0; h-2 > j; j+=2){
a[j][i] = '#';
mv--;
}
}else if(mv){
int j = 0;
for(;h > j && mv;j+=2){
a[j][i] = '#';
mv--;
}
j+=2;
for(;w > j; j+=2){
a[j][i] = '#';
}
}else{
for(int j = 2; h > j; j+=2){
a[j][i] = '#';
}
}
}
}else if((h+1)%4){
int mv = (x-(h+w-1)+1)/4;
for(int i = 1; h > i; i+=4){
if(w/2 <= mv){
//全部左側
for(int j = 0; w-2 > j; j+=2){
a[i][j] = '#';
mv--;
}
}else if(mv){
//mv個左側
int j = 0;
for(;w > j && mv; j+=2){
a[i][j] = '#';
mv--;
}
j+=2;
for(;w > j; j+=2){
a[i][j] = '#';
}
}else{
//全部左側
for(int j = 2; w > j; j+=2){
a[i][j] = '#';
}
}
}
for(int i = 3; h > i; i+=4){
for(int j = 2; w > j; j+=2){
a[i][j] = '#';
}
}
}else{
int mv = (x-(h+w-1)+1)/4;
for(int i = 1; w > i; i+=4){
if(h/2 <= mv){
for(int j = 0; h-2 > j; j+=2){
a[j][i] = '#';
mv--;
}
}else if(mv){
int j = 0;
for(;h > j && mv;j+=2){
a[j][i] = '#';
mv--;
}
j+=2;
for(;w > j; j+=2){
a[j][i] = '#';
}
}else{
for(int j = 2; h > j; j+=2){
a[j][i] = '#';
}
}
}
for(int i = 3; w > i; i+=4){
for(int j = 2; h > j; j+=2){
a[j][i] = '#';
}
}
}
for(int i = 0; h > i; i++){
for(int j = 0; w > j; j++){
cout << a[i][j];
}
cout << endl;
}
}
}